concurrent

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 2 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 provides a simple concurrent map implementation.

func MapOf

func MapOf[K comparable, V any](src map[K]V) *Map[K, V]

MapOf creates a new concurrent map wrapping the given map.

func (*Map[K, V]) Clear

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

Clear removes all elements from the map.

func (*Map[K, V]) Clone

func (cm *Map[K, V]) Clone() map[K]V

Clone returns a shallow copy of the map.

func (*Map[K, V]) Delete

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

Delete removes the value associated with the given key.

func (*Map[K, V]) Get

func (cm *Map[K, V]) Get(k K) (V, bool)

Get returns the value associated with the given key, and a boolean indicating whether the key was found.

func (*Map[K, V]) GetUnchecked

func (cm *Map[K, V]) GetUnchecked(k K) V

GetUnchecked returns the value associated with the given key without checking for its existence (nil if not found).

func (*Map[K, V]) Keys

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

Keys returns a slice of all keys in the map.

func (*Map[K, V]) Len

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

Len returns the number of elements in the map.

func (*Map[K, V]) Set

func (cm *Map[K, V]) Set(k K, v V)

Set sets the value associated with the given key.

func (*Map[K, V]) UpdateValue

func (cm *Map[K, V]) UpdateValue(key K, transformer ValueTransformer[V])

UpdateValue updates the value associated with the given key using the provided transformer function.

func (*Map[K, V]) Values

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

Values returns a slice of all values in the map.

type ValueTransformer

type ValueTransformer[V any] func(V) V

ValueTransformer is a function that transforms a value in the map.

Jump to

Keyboard shortcuts

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