concmap

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 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 ConcMap

type ConcMap[K comparable, V any] struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

ConcMap is a generic map safe for concurrent use. It uses a sync.RWMutex, so the map may be accessed by an arbitrary number of readers or a single writer.

func New

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

func (ConcMap[K, V]) Delete

func (cm ConcMap[K, V]) Delete(key K)

func (ConcMap[K, V]) DeleteIf

func (cm ConcMap[K, V]) DeleteIf(cond func(K, V) bool)

DeleteIf iterates over all map entries, and deletes them if the specified function returns true.

func (ConcMap[K, V]) Get

func (cm ConcMap[K, V]) Get(key K) V

func (ConcMap[K, V]) IsSet

func (cm ConcMap[K, V]) IsSet(key K) bool

func (ConcMap[K, V]) Iterate

func (cm ConcMap[K, V]) Iterate(f func(K, V))

Iterate through all elements in the map. Note that the map is locked during iteration, so invoking other methods will deadlock. To delete elements based on a condition, use DeleteIf.

func (ConcMap[K, V]) Set

func (cm ConcMap[K, V]) Set(key K, val V)

Jump to

Keyboard shortcuts

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