Documentation
¶
Index ¶
- type Map
- func (cm *Map[K, V]) Clear()
- func (cm *Map[K, V]) Clone() map[K]V
- func (cm *Map[K, V]) Delete(k K)
- func (cm *Map[K, V]) Get(k K) (V, bool)
- func (cm *Map[K, V]) GetUnchecked(k K) V
- func (cm *Map[K, V]) Keys() []K
- func (cm *Map[K, V]) Len() int
- func (cm *Map[K, V]) Set(k K, v V)
- func (cm *Map[K, V]) UpdateValue(key K, transformer ValueTransformer[V])
- func (cm *Map[K, V]) Values() []V
- type ValueTransformer
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 provides a simple concurrent map implementation.
func MapOf ¶
func MapOf[K comparable, V any](src map[K]V) *Map[K, V]
MapOf creates a new concurrent map wrapping the given map.
func (*Map[K, V]) Clone ¶
func (cm *Map[K, V]) Clone() map[K]V
Clone returns a shallow copy of the map.
func (*Map[K, V]) Delete ¶
func (cm *Map[K, V]) Delete(k K)
Delete removes the value associated with the given key.
func (*Map[K, V]) Get ¶
Get returns the value associated with the given key, and a boolean indicating whether the key was found.
func (*Map[K, V]) GetUnchecked ¶
func (cm *Map[K, V]) GetUnchecked(k K) V
GetUnchecked returns the value associated with the given key without checking for its existence (nil if not found).
func (*Map[K, V]) Keys ¶
func (cm *Map[K, V]) Keys() []K
Keys returns a slice of all keys in the map.
func (*Map[K, V]) Set ¶
func (cm *Map[K, V]) Set(k K, v V)
Set sets the value associated with the given key.
func (*Map[K, V]) UpdateValue ¶
func (cm *Map[K, V]) UpdateValue(key K, transformer ValueTransformer[V])
UpdateValue updates the value associated with the given key using the provided transformer function.
type ValueTransformer ¶
type ValueTransformer[V any] func(V) V
ValueTransformer is a function that transforms a value in the map.