refactor: HashTable -> Table, table -> subtable
All checks were successful
CI / Check PR Title (pull_request) Successful in 29s
CI / Go Lint (pull_request) Successful in 39s
CI / Makefile Lint (pull_request) Successful in 48s
CI / Markdown Lint (pull_request) Successful in 31s
CI / Unit Tests (pull_request) Successful in 37s
CI / Fuzz Tests (pull_request) Successful in 1m38s
CI / Mutation Tests (pull_request) Successful in 1m19s
All checks were successful
CI / Check PR Title (pull_request) Successful in 29s
CI / Go Lint (pull_request) Successful in 39s
CI / Makefile Lint (pull_request) Successful in 48s
CI / Markdown Lint (pull_request) Successful in 31s
CI / Unit Tests (pull_request) Successful in 37s
CI / Fuzz Tests (pull_request) Successful in 1m38s
CI / Mutation Tests (pull_request) Successful in 1m19s
This commit is contained in:
14
settings.go
14
settings.go
@@ -2,18 +2,18 @@ package cuckoo
|
||||
|
||||
import "fmt"
|
||||
|
||||
// DefaultCapacity is the initial capacity of a [HashTable]. It is inspired from
|
||||
// DefaultCapacity is the initial capacity of a [Table]. It is inspired from
|
||||
// Java's [HashMap] implementation, which also uses 16.
|
||||
//
|
||||
// [HashMap]: https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html#HashMap--
|
||||
const DefaultCapacity uint64 = 16
|
||||
|
||||
// DefaultGrowthFactor is the standard resize multiplier for a [HashTable]. Most
|
||||
// DefaultGrowthFactor is the standard resize multiplier for a [Table]. Most
|
||||
// implementations use 2.
|
||||
const DefaultGrowthFactor uint64 = 2
|
||||
|
||||
// defaultMinimumLoad is the default lowest acceptable occupancy of a [HashTable].
|
||||
// The higher the minimum load, the more likely that a [HashTable.Put] will not
|
||||
// defaultMinimumLoad is the default lowest acceptable occupancy of a [Table].
|
||||
// The higher the minimum load, the more likely that a [Table.Put] will not
|
||||
// succeed. The value of 5% is taken from [libcuckoo].
|
||||
//
|
||||
// [libcuckoo]: https://github.com/efficient/libcuckoo/blob/656714705a055df2b7a605eb3c71586d9da1e119/libcuckoo/cuckoohash_config.hh#L21
|
||||
@@ -25,11 +25,11 @@ type settings struct {
|
||||
bucketSize uint64
|
||||
}
|
||||
|
||||
// An Option modifies the settings of a [HashTable]. It is used in its constructors
|
||||
// An Option modifies the settings of a [Table]. It is used in its constructors
|
||||
// like [New], for example.
|
||||
type Option func(*settings)
|
||||
|
||||
// Capacity modifies the starting capacity of each table of the [HashTable]. The
|
||||
// Capacity modifies the starting capacity of each subtable of the [Table]. The
|
||||
// value must be non-negative.
|
||||
func Capacity(value int) Option {
|
||||
if value < 0 {
|
||||
@@ -39,7 +39,7 @@ func Capacity(value int) Option {
|
||||
return func(s *settings) { s.bucketSize = uint64(value) }
|
||||
}
|
||||
|
||||
// GrowthFactor controls how much the capacity of the [HashTable] multiplies when
|
||||
// GrowthFactor controls how much the capacity of the [Table] multiplies when
|
||||
// it must resize. The value must be greater than 1.
|
||||
func GrowthFactor(value int) Option {
|
||||
if value < 2 {
|
||||
|
||||
Reference in New Issue
Block a user