safe

package
v0.0.108 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

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 is a thread safe generic map.

func NewMap

func NewMap[K comparable, V any]() Map[K, V]

NewMap creates a new thread safe map.

func NewMapWithData

func NewMapWithData[K comparable, V any](data map[K]V) Map[K, V]

NewMapWithData creates a new thread safe map with initial data.

func (*Map[K, V]) Delete

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

Delete removes a key from the map.

func (*Map[K, V]) Len added in v0.0.75

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

func (*Map[K, V]) Load

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

Load returns the value stored in the map for a key, otherwise false if no value is present.

func (*Map[K, V]) LoadOrStore added in v0.0.93

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

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(f func(k K, v V) bool)

Range iterates over the map, calling the provided function for each key/value pair. If the function returns false, the iteration stops.

func (*Map[K, V]) Store

func (m *Map[K, V]) Store(k K, v V)

Store sets the value for a key.

func (*Map[K, V]) UpdateInTx

func (m *Map[K, V]) UpdateInTx(updateFunc func(map[K]V))

UpdateInTx allows to update the map in a transactional way.

Jump to

Keyboard shortcuts

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