sync

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package sync provides utilities for synchronization.

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 synchronized map. It is a wrapper around Go's standard sync.Map, with all the same caveats.

func (*Map[K, V]) Delete

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

Delete removes a pair given a key.

func (*Map[K, V]) Empty

func (sm *Map[K, V]) Empty() bool

Empty returns true if the map is empty.

func (*Map[K, V]) Iter

func (sm *Map[K, V]) Iter() func(func(K, V) bool)

Iter returns an iterator to range over the elements of the map.

func (*Map[K, V]) Load

func (sm *Map[K, V]) Load(k K) (v V)

Load returns a value given a key.

func (*Map[K, V]) LoadAndDelete

func (sm *Map[K, V]) LoadAndDelete(k K) (any, bool)

LoadAndDelete deletes the value for a key, returning the previous value (if any) and whether the key was present.

func (*Map[K, V]) Size

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

Size returns the number of elements in the map. This takes O(n) time.

func (*Map[K, V]) Store

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

Store a key,value pair.

Jump to

Keyboard shortcuts

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