Documentation
¶
Overview ¶
Package maps provides a generic allocated map implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteMap ¶
type ByteMap struct {
// contains filtered or unexported fields
}
ByteMap is a Robin Hood hashmap operating on raw byte keys and values. Most users will want to use the generic Map wrapper type instead.
func NewByteMap ¶
NewByteMap creates a new ByteMap with the given initial capacity, key size, and value size, using the provided allocator (or the default allocator if nil). The map automatically grows as needed.
If the allocator is nil, uses the system allocator. The caller is responsible for freeing map resources with ByteMap.Free when done using it.
func (*ByteMap) Clear ¶
func (m *ByteMap) Clear()
Clear removes all key-value pairs from the map, resetting it to an empty state. Does not free map resources; the map can be reused after Clear.
func (*ByteMap) Free ¶
func (m *ByteMap) Free()
Free frees internal resources used by the map. If the map is already freed, does nothing. The map must not be used after Free.
type Iter ¶
type Iter[K comparable, V any] struct { // contains filtered or unexported fields }
Iter is an iterator over a Map's key-value pairs.
func (*Iter[K, V]) Key ¶
func (it *Iter[K, V]) Key() K
Key returns the key of the current key-value pair.
func (*Iter[K, V]) Next ¶
Next advances the iterator to the next key-value pair, which will then be available through the Iter.Key and Iter.Value methods. It returns false if there are no more pairs to iterate over.
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a generic hashmap similar to Go's built-in map[K]V. It automatically grows as needed, but does not shrink.
func (*Map[K, V]) Clear ¶
func (m *Map[K, V]) Clear()
Clear removes all key-value pairs from the map, resetting it to an empty state. Does not free map resources; the map can be reused after Clear.
func (*Map[K, V]) Delete ¶
func (m *Map[K, V]) Delete(key K)
Delete removes the key and its value from the map. If the key is not in the map, does nothing.
func (*Map[K, V]) Free ¶
func (m *Map[K, V]) Free()
Free frees internal resources used by the map. If the map is already freed, does nothing. The map must not be used after calling Free.
func (*Map[K, V]) Get ¶
func (m *Map[K, V]) Get(key K) V
Get returns the value for the given key, or the zero value if the key is not in the map.
func (*Map[K, V]) Iter ¶
Iter returns an iterator over the map's key-value pairs. The map must not be modified or freed while iterating.