atomic

package
v8.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapAllF

func MapAllF[K comparable, V any, U any](m *Map[K, V], f func(map[K]V) U) U

Types

type Map

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Map implements a Map with atomic semantics.

func New

func New[K comparable, V any](length int) *Map[K, V]

New generates a new Map instance.

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

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

Clear will remove all entries.

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

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

CloneAndResetMap copies the map and resets the original map.

func (*Map[K, V]) CloneMap added in v8.3.0

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

CloneMap copies the map and returns the copy.

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

func (m *Map[K, V]) Exists(k K) bool

Exists atomically checks if a key exists in the map

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

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

Returns the keys from the map.

func (*Map[K, V]) Length

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

Length returns the Map size.

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.

Jump to

Keyboard shortcuts

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