Documentation
¶
Index ¶
- Constants
- type HashMap
- func (m *HashMap[K, V]) Del(key K)
- func (m *HashMap[K, V]) Fillrate() uintptr
- func (m *HashMap[K, V]) ForEach(lambda func(K, V))
- func (m *HashMap[K, V]) Get(key K) (value V, ok bool)
- func (m *HashMap[K, V]) Grow(newSize uintptr)
- func (m *HashMap[K, V]) Len() uintptr
- func (m *HashMap[K, V]) Set(key K, value V)
- func (m *HashMap[K, V]) SetHasher(hs func(K) uintptr)
Constants ¶
const ( // DefaultSize is the default size for a zero allocated map DefaultSize = 256 // MaxFillRate is the maximum fill rate for the slice before a resize will happen. MaxFillRate = 50 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashMap ¶
type HashMap[K hashable, V any] struct { // contains filtered or unexported fields }
HashMap implements a read optimized hash map.
func (*HashMap[K, V]) Fillrate ¶
func (m *HashMap[K, V]) Fillrate() uintptr
Fillrate returns the fill rate of the map as an percentage integer.
func (*HashMap[K, V]) ForEach ¶
func (m *HashMap[K, V]) ForEach(lambda func(K, V))
ForEach iterates over key-value pairs and executes the lambda provided for each such pair.
func (*HashMap[K, V]) Get ¶
func (m *HashMap[K, V]) Get(key K) (value V, ok bool)
Get retrieves an element from the map under given hash key.
func (*HashMap[K, V]) Grow ¶
func (m *HashMap[K, V]) Grow(newSize uintptr)
Grow resizes the hashmap to a new size, gets rounded up to next power of 2. To double the size of the hashmap use newSize 0. This function returns immediately, the resize operation is done in a goroutine. No resizing is done in case of another resize operation already being in progress.
func (*HashMap[K, V]) Len ¶
func (m *HashMap[K, V]) Len() uintptr
Len returns the number of key-value pairs within the map.
func (*HashMap[K, V]) Set ¶
func (m *HashMap[K, V]) Set(key K, value V)
Set sets the value under the specified key to the map. An existing item for this key will be overwritten. If a resizing operation is happening concurrently while calling Set, the item might show up in the map only after the resize operation is finished.