syncmap

package
v0.22.9 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT 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[Key comparable, Value any] sync.Map

func (*Map[Key, Value]) Delete

func (m *Map[Key, Value]) Delete(key Key)

Deletes the value for the passed key. If the key has no corresponding value, the map is unchanged.

func (*Map[Key, Value]) Empty

func (m *Map[Key, Value]) Empty() bool

Returns true if the map is empty. Note that this is point-in-time check, and the map might be modified immediately after this method returns.

func (*Map[Key, Value]) Load

func (m *Map[Key, Value]) Load(key Key) (Value, bool)

Returns the value stored in the map (if found), and a boolean indicating whether the value was found.

func (*Map[Key, Value]) LoadAndDelete

func (m *Map[Key, Value]) LoadAndDelete(key Key) (Value, bool)

Loads and deletes the value for the passed key. If the key has no corresponding value, the map is unchanged and the returned boolean is false.

func (*Map[Key, Value]) LoadOrStore

func (m *Map[Key, Value]) LoadOrStore(key Key, newValue Value) (Value, bool)

Loads and returns the value for for the passed key. If the key has no corresponding value, the newValue is stored and returned. The returned boolean is true if the value was already in the map, and false if the new value was stored.

func (*Map[Key, Value]) LoadOrStoreNew

func (m *Map[Key, Value]) LoadOrStoreNew(key Key, valueFactory func() Value) (Value, bool)

Loads and returns the value for for the passed key. If the key has no corresponding value, a new value is created using the passed valueFactory, then stored and returned. The returned boolean is true if the value was already in the map, and false if the new value was stored.

Note: in high-contention conditions the value factory function might be called even if the key is already in the map. If this happens, the existing value is returned and the new value is discarded.

func (*Map[Key, Value]) Range

func (m *Map[Key, Value]) Range(f func(key Key, value Value) bool)

Calls passed function foreach key-value pair in the map. If the function returns false, the iteration stops.

func (*Map[Key, Value]) Store

func (m *Map[Key, Value]) Store(key Key, value Value)

Jump to

Keyboard shortcuts

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