Documentation
¶
Index ¶
- type Map
- func (m *Map[K, V]) Del(keys ...K)
- func (m *Map[K, V]) Fillrate() uintptr
- func (m *Map[K, V]) ForEach(lambda func(K, V) bool)
- func (m *Map[K, V]) Get(key K) (value V, ok bool)
- func (m *Map[K, V]) GetOrSet(key K, value V) (actual V, loaded bool)
- func (m *Map[K, V]) Grow(newSize uintptr)
- func (m *Map[K, V]) Len() uintptr
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) SetHasher(hs func(K) uintptr)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶ added in v1.0.0
type Map[K hashable, V any] struct { // contains filtered or unexported fields }
Map implements the concurrent hashmap
func (*Map[K, V]) Del ¶ added in v1.0.0
func (m *Map[K, V]) Del(keys ...K)
Del deletes key/keys from the map Bulk deletion is more efficient than deleting keys one by one
func (*Map[K, V]) Fillrate ¶ added in v1.0.0
func (m *Map[K, V]) Fillrate() uintptr
Fillrate returns the fill rate of the map as an percentage integer
func (*Map[K, V]) ForEach ¶ added in v1.0.0
func (m *Map[K, V]) ForEach(lambda func(K, V) bool)
ForEach iterates over key-value pairs and executes the lambda provided for each such pair lambda must return `true` to continue iteration and `false` to break iteration
func (*Map[K, V]) Get ¶ added in v1.0.0
func (m *Map[K, V]) Get(key K) (value V, ok bool)
Get retrieves an element from the map returns `false“ if element is absent
func (*Map[K, V]) GetOrSet ¶ added in v1.1.0
func (m *Map[K, V]) GetOrSet(key K, value V) (actual V, loaded bool)
GetOrSet returns the existing value for the key if present Otherwise, it stores and returns the given value The loaded result is true if the value was loaded, false if stored
func (*Map[K, V]) Grow ¶ added in v1.0.0
func (m *Map[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 No resizing is done in case of another resize operation already being in progress Growth and map bucket policy is inspired from https://github.com/cornelk/hashmap
func (*Map[K, V]) Len ¶ added in v1.0.0
func (m *Map[K, V]) Len() uintptr
Len returns the number of key-value pairs within the map
func (*Map[K, V]) Set ¶ added in v1.0.0
func (m *Map[K, V]) Set(key K, value V)
Set tries to update an element if key is present else it inserts a new element If a resizing operation is happening concurrently while calling Set() then the item might show up in the map only after the resize operation is finished