swiss

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT, Apache-2.0 Imports: 4 Imported by: 0

README

swiss

Golang port of Abseil's flat_hash_map

Documentation

Index

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 NewMap

func NewMap[K comparable, V any](sz uint32) (m *Map[K, V])

NewMap constructs a Map.

func (*Map[K, V]) Clear

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

Clear removes all elements from the Map.

func (*Map[K, V]) Count

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

Count returns the number of elements in the Map.

func (*Map[K, V]) DeleteWithHash

func (m *Map[K, V]) DeleteWithHash(key K, hash uint64) (ok bool)

func (*Map[K, V]) GetWithHash

func (m *Map[K, V]) GetWithHash(key K, hash uint64) (value V, ok bool)

func (*Map[K, V]) HasWithHash

func (m *Map[K, V]) HasWithHash(key K, hash uint64) (ok bool)

func (*Map[K, V]) Iter

func (m *Map[K, V]) Iter(cb func(k K, v V) (stop bool)) bool

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

func (m *Map[K, V]) PutWithHash(key K, value V, hash uint64)

Put attempts to insert |key| and |value|

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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