Documentation ¶
Overview ¶
Package cuckoo implements d-ary bucketized cuckoo hashing with stash (bucketized cuckoo hashing is also known as splash tables). This implementation uses configurable number of hash functions and cells per bucket. Greedy algorithm for collision resolution is a random walk.
Index ¶
Constants ¶
const (
DefaultLogSize = 8 + bshift // A reasonable logsize value for NewCuckoo for use when the number of items to be inserted is not known ahead.
)
other configurable variables
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cuckoo ¶
type Cuckoo struct {
// contains filtered or unexported fields
}
Cuckoo implements a memory-efficient map[Key]Value equivalent where Key is an integer and Value can be anything. Similar to built-in maps Cuckoo is not thread-safe. In a parallel environment you may need to wrap access with mutexes.
func (*Cuckoo) ForRange ¶
ForRange loops over all (key,value) pairs in the hash map and calls f for each.
func (*Cuckoo) Insert ¶
Insert adds given key/value item into the hash map. If an item with key k already exists, it will be replaced.
func (*Cuckoo) LoadFactor ¶
LoadFactor returns the load factor of the hash table, which is the ratio of the used cells to the allocated cells.