Documentation ¶
Overview ¶
Package containers provides generic containers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BiMap ¶
type BiMap[K comparable, V comparable] struct { // contains filtered or unexported fields }
BiMap (or “bidirectional map”) is a special kind of map that maintains an inverse view of the map while ensuring that no duplicate values are present and a value can always be used safely to get the key back.
type ConcurrentMap ¶
type ConcurrentMap[K comparable, V any] struct { // contains filtered or unexported fields }
ConcurrentMap is a map that can be safely accessed from multiple goroutines.
func (*ConcurrentMap[K, V]) Clear ¶
func (m *ConcurrentMap[K, V]) Clear()
Clear removes all key-value pairs.
func (*ConcurrentMap[K, V]) ForEach ¶
func (m *ConcurrentMap[K, V]) ForEach(f func(K, V))
ForEach calls the given function for each key-value pair.
func (*ConcurrentMap[K, V]) Get ¶
func (m *ConcurrentMap[K, V]) Get(key K) (V, bool)
Get returns the value for the given key.
func (*ConcurrentMap[K, V]) Remove ¶
func (m *ConcurrentMap[K, V]) Remove(key K)
Remove removes the value for the given key.
func (*ConcurrentMap[K, V]) Set ¶
func (m *ConcurrentMap[K, V]) Set(key K, val V)
Set sets the value for the given key.
type LazyBiMap ¶
type LazyBiMap[K comparable, V comparable] struct { Creator func(K) (V, error) // contains filtered or unexported fields }
LazyBiMap is like BiMap but creates values on demand.
func (*LazyBiMap[K, V]) GetOrCreate ¶
GetOrCreate returns the value for the given key.
type LazyMap ¶
type LazyMap[K comparable, V comparable] struct { Creator func(K) (V, error) // contains filtered or unexported fields }
LazyMap is like usual map but creates values on demand.
func (*LazyMap[K, V]) GetOrCreate ¶
GetOrCreate returns the value for the given key. It creates it using Creator if it doesn't exist.