Documentation ¶
Overview ¶
Package rhmap provides a map[[]byte][]byte based on the robin-hood hashmap algorithm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNilKey = errors.New("nil key")
ErrNilKey means a key was nil.
Functions ¶
Types ¶
type RHMap ¶
type RHMap struct { // Items are the slots of the hashmap for items. Items []Item // Number of keys in the RHMap. Count int // Overridable hash func. Defaults to hash/fnv.New32a(). HashFunc func(Key) uint32 // When any item's distance gets too large, grow the RHMap. // Defaults to 10. MaxDistance int // Overridable func to calculate a size multiplier when resizing // for growth is needed. Default returns a constant 2.0. Growth func(*RHMap) float64 // Overridable func to grow the RHMap. Grow func(m *RHMap, newSize int) }
RHMap is a hashmap that uses the robinhood algorithm. This implementation is not concurrent safe.
func (*RHMap) Del ¶
Del removes a key/val from the RHMap. The previous val, if it existed, is returned.
func (*RHMap) Reset ¶
func (m *RHMap) Reset()
Reset clears RHMap, where already allocated memory will be reused.
func (*RHMap) Set ¶
Set inserts or updates a key/val into the RHMap. The returned wasNew will be true if the mutation was on a newly seen, inserted key, and wasNew will be false if the mutation was an update to an existing key.
NOTE: RHMap does not keep its own copy of the key/val's. Especially, applications should take care not to mutate the key. Careful mutations to the val bytes that do not resize the val slice, however, should work.