hashmap

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 7 Imported by: 0

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

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

func (m *Map[K, V]) All() iter.Seq2[K, V]

All returns an iterator over the key/value entries of the map in undefined order.

func (*Map[K, V]) Clear

func (m *Map[K, V]) Clear()

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(key K) (V, bool)

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

func (m *Map[K, V]) Get(key K) (V, bool)

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]) Keys

func (m *Map[K, V]) Keys() iter.Seq[K]

Keys returns an iterator over the map keys in unspecified order.

func (*Map[K, V]) Len

func (m *Map[K, V]) Len() int

Len returns the number of map entries.

func (*Map[K, V]) Set

func (m *Map[K, V]) Set(key K, value V) (prev V, changed bool)

Set updates the map entry for key to value and returns the previous entry, if any. It reports whether the map size increased.

func (*Map[K, V]) String

func (m *Map[K, V]) String() string

String returns a string representation of the map's entries in an unspecified but deterministic order.

Keys and values are printed as if by fmt.Sprint.

func (*Map[K, V]) Values

func (m *Map[K, V]) Values() iter.Seq[V]

Values returns an iterator over the map values in unspecified order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL