Documentation
¶
Index ¶
- type Flat
- func (m *Flat[K, V]) Clear()
- func (m *Flat[K, V]) Copy() *Flat[K, V]
- func (m *Flat[K, V]) Each(fn func(key K, val V) bool)
- func (m *Flat[K, V]) Get(key K) (V, bool)
- func (m *Flat[K, V]) Load() float32
- func (m *Flat[K, V]) MaxLoad(lf float32) error
- func (m *Flat[K, V]) Put(key K, val V) bool
- func (m *Flat[K, V]) Remove(key K) bool
- func (m *Flat[K, V]) Reserve(n uintptr)
- func (m *Flat[K, V]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flat ¶
type Flat[K comparable, V any] struct { // contains filtered or unexported fields }
Flat is a open addressing hashmap implementation which uses linear probing to solve conflicts.
func New ¶
func New[K comparable, V any]() *Flat[K, V]
New creates a new ready to use flat hashmap.
Note: This hashmap has a zero memory overhead per bucket and uses therefore the golang default variable initialization representation as tracking. This means in details a Get, Put or Remove call fails, if the key is:
- 0 (int, uint, uint64, ...)
- 0.0 (float32, float64)
- "" (string)
func NewWithHasher ¶
func NewWithHasher[K comparable, V any](empty K, hasher shared.HashFn[K]) *Flat[K, V]
NewWithHasher constructs a new hashmap with the given hasher. Furthermore the representation for a empty bucket can be set.
func (*Flat[K, V]) Clear ¶
func (m *Flat[K, V]) Clear()
Clear removes all key-value pairs from the hashmap.
func (*Flat[K, V]) Each ¶
Each calls 'fn' on every key-value pair in the hashmap in no particular order.
func (*Flat[K, V]) MaxLoad ¶
MaxLoad forces resizing if the ratio is reached. Useful values are in range [0.5-0.7]. Returns ErrOutOfRange if `lf` is not in the open range (0.0,1.0).
func (*Flat[K, V]) Put ¶
Put adds the given key-value pair to the hashmap. If the key already exists its value will be overwritten with the new value.