concurrentmap

package
v0.38.0-util Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: AGPL-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 map.

func New

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

New returns a new Map with the given types

func (*Map[K, V]) Add

func (p *Map[K, V]) Add(key K, value V)

Add adds a key-value pair to the map

func (*Map[K, V]) Clear

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

func (*Map[K, V]) ForEach

func (p *Map[K, V]) ForEach(fn func(k K, v V) error) error

ForEach iterates over the map and calls the given function for each key-value pair. If the function returns an error, the iteration is stopped and the error is returned.

func (*Map[K, V]) Get

func (p *Map[K, V]) Get(key K) (V, bool)

Get returns the value for the given key and a boolean indicating if the key was found

func (*Map[K, V]) Has

func (p *Map[K, V]) Has(key K) bool

Has returns true if the map contains the given key

func (*Map[K, V]) Remove

func (p *Map[K, V]) Remove(key K)

Remove removes a key-value pair from the map

func (*Map[K, V]) Size

func (p *Map[K, V]) Size() int

Size returns the size of the map.

Jump to

Keyboard shortcuts

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