Documentation
¶
Overview ¶
Package hashmaps collects several types of hashmaps.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.5.0
type Config[K comparable, V any] struct { Type Type // Size grows the hashmap to the desired size. // If unset `DefaultSize` is used. Size uintptr // MaxLoad changes the load factor of the hashmap. // This value is a trade-off between performance and memory consumption. // If unset `DefaultMaxLoad` is used. MaxLoad float32 // Hasher that is used. Must be configured for complex data types or slices. // If unset a default hasher is used for golang basic types. Hasher shared.HashFn[K] // Empty is used by some hash hashmap implementations e.g.: flat hashmap // to track empty buckets. Empty K }
Config is used by the factory to create and configure a hashmap instance.
type HashMap ¶ added in v0.5.0
type HashMap[K comparable, V any] struct { Get func(key K) (V, bool) Put func(key K, val V) bool Remove func(key K) bool Reserve func(n uintptr) Load func() float32 Clear func() Size func() int Each func(fn func(key K, val V) bool) MaxLoad func(lf float32) error }
HashMap is the basic hashmap interface as a set of function points.
func MustNewHashMap ¶ added in v0.5.0
func MustNewHashMap[K comparable, V any](cfg Config[K, V]) *HashMap[K, V]
MustNewHashMap same as 'NewHashMap' but panics if and only if an error occurs.
func NewHashMap ¶ added in v0.5.0
func NewHashMap[K comparable, V any](cfg Config[K, V]) (*HashMap[K, V], error)
NewHashMap is a factory function to instantiate different kind of generic hashmap implementations. A struct with function pointers is used as interface. In most cases the usage of the dedicate hashmap type is recommended.
Click to show internal directories.
Click to hide internal directories.