mapx

package
v0.0.0-...-3511abf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.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 generic, thread-safe map to supersede usages of sync.Map.

func New

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

New creates an empty map.

func (*Map[K, V]) Clear

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

Clear the map.

func (*Map[K, V]) Delete

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

Delete the value corresponding to k, idempotently.

func (*Map[K, V]) Len

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

Len of the map (number of stored pairs).

func (*Map[K, V]) Load

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

Load the value corresponding to k.

func (*Map[K, V]) Store

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

Store the (k,v) pair.

func (*Map[K, V]) Values

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

Values returns the list of values in the map.

func (*Map[K, V]) WithLock

func (m *Map[K, V]) WithLock(f func(m map[K]V))

WithLock runs the given function on the underlying map with a write lock.

Jump to

Keyboard shortcuts

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