Documentation
¶
Index ¶
- func MapAllF[K comparable, V any, U any](m *Map[K, V], f func(map[K]V) U) U
- type Map
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Clone() map[K]V
- func (m *Map[K, V]) CloneAndResetMap() *Map[K, V]
- func (m *Map[K, V]) CloneMap() *Map[K, V]
- func (m *Map[K, V]) Delete(k K) V
- func (m *Map[K, V]) DeleteAll(ks ...K)
- func (m *Map[K, V]) DeleteAllDeref(ks ...*K)
- func (m *Map[K, V]) DeleteDeref(k *K) V
- func (m *Map[K, V]) Exists(k K) bool
- func (m *Map[K, V]) Get(k K) V
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Length() int
- func (m *Map[K, V]) Replace(nm map[K]V)
- func (m *Map[K, V]) Set(k K, v V)
- func (mp *Map[K, V]) UpdateOrInsert(key K, updateFn func(V) V, defaultVal V) V
- func (mp *Map[K, V]) UpdateOrInsertFn(key K, updateFn func(V) V, defaultValFn func() V) V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map implements a Map with atomic semantics.
func NewWithValue ¶ added in v8.3.0
func NewWithValue[K comparable, V any](k K, v V) *Map[K, V]
New generates a new Map instance with initial entry.
func (*Map[K, V]) Clone ¶
func (m *Map[K, V]) Clone() map[K]V
Clone copies the map and returns the copy.
func (*Map[K, V]) CloneAndResetMap ¶ added in v8.3.0
CloneAndResetMap copies the map and resets the original map.
func (*Map[K, V]) Delete ¶
func (m *Map[K, V]) Delete(k K) V
Delete will remove the key and return its value.
func (*Map[K, V]) DeleteAll ¶
func (m *Map[K, V]) DeleteAll(ks ...K)
DeleteAllDeref will dereferences and removes the keys.
func (*Map[K, V]) DeleteAllDeref ¶
func (m *Map[K, V]) DeleteAllDeref(ks ...*K)
DeleteAll will remove the keys.
func (*Map[K, V]) DeleteDeref ¶
func (m *Map[K, V]) DeleteDeref(k *K) V
DeleteDeref will dereference and remove the key and return its value.
func (*Map[K, V]) Get ¶
func (m *Map[K, V]) Get(k K) V
Get atomically retrieves an element from the Map.
func (*Map[K, V]) Replace ¶
func (m *Map[K, V]) Replace(nm map[K]V)
Replace replaces the internal map with the provided one.
func (*Map[K, V]) Set ¶
func (m *Map[K, V]) Set(k K, v V)
Set atomically sets an element in the Map. If idx is out of range, it will return an error.
func (*Map[K, V]) UpdateOrInsert ¶ added in v8.3.0
func (mp *Map[K, V]) UpdateOrInsert(key K, updateFn func(V) V, defaultVal V) V
UpdateOrInsert will update the value if it exists, otherwise it will insert the default value.
func (*Map[K, V]) UpdateOrInsertFn ¶ added in v8.3.0
func (mp *Map[K, V]) UpdateOrInsertFn(key K, updateFn func(V) V, defaultValFn func() V) V
UpdateOrInsert will update the value if it exists, otherwise it will insert the default value.