Documentation
¶
Overview ¶
Package hashmap provides a hash table with custom hashing and key equivalence.
Map is adapted from the proposed standard library container/hash.Map: https://go.dev/issue/69559.
TODO: Replace this package with container/hash once it is available in the minimum Go version supported by this module.
Index ¶
- type Map
- func (m *Map[K, V]) All() iter.Seq2[K, V]
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Delete(key K) (V, bool)
- func (m *Map[K, V]) Get(key K) (V, bool)
- func (m *Map[K, V]) Keys() iter.Seq[K]
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Set(key K, value V) (prev V, changed bool)
- func (m *Map[K, V]) String() string
- func (m *Map[K, V]) Values() iter.Seq[V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K, V any] struct { // contains filtered or unexported fields }
Map is a mapping from keys of type K to values of type V, using the hash function and key-equivalence relation specified at construction. Map values must not be copied.
func NewMap ¶
func NewMap[K, V any](h internalmaphash.Hasher[K]) *Map[K, V]
NewMap returns a new mapping.
func (*Map[K, V]) All ¶
All returns an iterator over the key/value entries of the map in undefined order.
func (*Map[K, V]) Delete ¶
Delete removes the entry with the given key, if present. It reports whether the map changed, and returns the previous value, if any.
func (*Map[K, V]) Get ¶
Get reports whether the map contains the specified key, and returns the corresponding value if found, or the zero value if not.
func (*Map[K, V]) Set ¶
Set updates the map entry for key to value and returns the previous entry, if any. It reports whether the map size increased.