docs: replaced instances of "bucket" with "table"

- Removed instances of `growthFactor`, as it is unexported.
- Typo in `HashTable.String()`.
This commit is contained in:
2026-04-13 20:49:33 -04:00
parent 395a3560c7
commit 6a5b40c097
3 changed files with 6 additions and 6 deletions

View File

@@ -45,7 +45,7 @@ func (t *HashTable[K, V]) load() float64 {
return float64(t.Size()) / float64(t.TotalCapacity()) return float64(t.Size()) / float64(t.TotalCapacity())
} }
// resize clears all buckets, changes the sizes of them to a specific capacity, // resize clears all tables, changes the sizes of them to a specific capacity,
// and fills them back up again. It is a helper function for [HashTable.grow] and // and fills them back up again. It is a helper function for [HashTable.grow] and
// [HashTable.shrink]; use them instead. // [HashTable.shrink]; use them instead.
func (t *HashTable[K, V]) resize(capacity uint64) error { func (t *HashTable[K, V]) resize(capacity uint64) error {
@@ -66,7 +66,7 @@ func (t *HashTable[K, V]) resize(capacity uint64) error {
return nil return nil
} }
// grow increases the table's capacity by the [HashTable.growthFactor]. If the // grow increases the table's capacity by the growth factor. If the
// capacity is 0, it increases it to 1. // capacity is 0, it increases it to 1.
func (t *HashTable[K, V]) grow() error { func (t *HashTable[K, V]) grow() error {
var newCapacity uint64 var newCapacity uint64
@@ -80,7 +80,7 @@ func (t *HashTable[K, V]) grow() error {
return t.resize(newCapacity) return t.resize(newCapacity)
} }
// shrink reduces the table's capacity by the [HashTable.growthFactor]. It may // shrink reduces the table's capacity by the growth factor. It may
// reduce it down to 0. // reduce it down to 0.
func (t *HashTable[K, V]) shrink() error { func (t *HashTable[K, V]) shrink() error {
return t.resize(t.tableA.capacity / t.growthFactor) return t.resize(t.tableA.capacity / t.growthFactor)
@@ -173,7 +173,7 @@ func (t *HashTable[K, V]) Entries() iter.Seq2[K, V] {
} }
// String returns the entries of the table as a string in the format: // String returns the entries of the table as a string in the format:
// "table[k1:v1 h2:v2 ...]". // "table[k1:v1 k2:v2 ...]".
func (t *HashTable[K, V]) String() string { func (t *HashTable[K, V]) String() string {
var sb strings.Builder var sb strings.Builder
sb.WriteString("table[") sb.WriteString("table[")

View File

@@ -29,7 +29,7 @@ type settings struct {
// like [New], for example. // like [New], for example.
type Option func(*settings) type Option func(*settings)
// Capacity modifies the starting capacity of each bucket of the [HashTable]. The // Capacity modifies the starting capacity of each table of the [HashTable]. The
// value must be non-negative. // value must be non-negative.
func Capacity(value int) Option { func Capacity(value int) Option {
if value < 0 { if value < 0 {

View File

@@ -17,7 +17,7 @@ type table[K, V any] struct {
compare EqualFunc[K] compare EqualFunc[K]
} }
// location determines where in the bucket a certain key would be placed. If the // location determines where in the table a certain key would be placed. If the
// capacity is 0, this will panic. // capacity is 0, this will panic.
func (t table[K, V]) location(key K) uint64 { func (t table[K, V]) location(key K) uint64 {
return t.hash(key) % t.capacity return t.hash(key) % t.capacity