Documentation
¶
Index ¶
- type Map
- func (m *Map[K, V]) Capacity() int
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Count() int
- func (m *Map[K, V]) Delete(key K) (ok bool)
- func (m *Map[K, V]) Get(key K) (value V, ok bool)
- func (m *Map[K, V]) Has(key K) (ok bool)
- func (m *Map[K, V]) Iter(cb func(k K, v V) (stop bool))
- func (m *Map[K, V]) Put(key K, value V)
- func (m *Map[K, V]) Shift(key K, amount V)
- func (m *Map[K, V]) Shift2(key K, amount V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is an open-addressing hash map based on Abseil's flat_hash_map.
func (*Map[K, V]) Capacity ¶
Capacity returns the number of additional elements the can be added to the Map before resizing.
func (*Map[K, V]) Iter ¶
Iter iterates the elements of the Map, passing them to the callback. It guarantees that any key in the Map will be visited only once, and for un-mutated Maps, every key will be visited once. If the Map is Mutated during iteration, mutations will be reflected on return from Iter, but the set of keys visited by Iter is non-deterministic.
func (*Map[K, V]) Put ¶
func (m *Map[K, V]) Put(key K, value V)
Put attempts to insert |key| and |value|
func (*Map[K, V]) Shift ¶
func (m *Map[K, V]) Shift(key K, amount V)
Shift increments the value associated with the given key by the specified amount. If the key doesn't exist, it inserts a new key-value pair with the amount as the value.
func (*Map[K, V]) Shift2 ¶
func (m *Map[K, V]) Shift2(key K, amount V)
Shift2 increments the value associated with the given key by the specified amount. If the key doesn't exist, it inserts a new key-value pair with the amount as the value. Concept is same as Shift, but Get and Push are now inlined