containers

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicMap

type AtomicMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

mmap is a struct that protects a standard library map with a mutex. All functions of mmap are thead-safe map operations.

Mmap exists as an alternative to sync.Map as a datastructure that does not necessarily require an allocation for each of its elements. Sync.Map always requires an allocation for each element inserted into it.

func (*AtomicMap[K, V]) Clear

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

Clear is a function that removes all elements from the map.

func (*AtomicMap[K, V]) LoadOrStore

func (m *AtomicMap[K, V]) LoadOrStore(key K, value V) (V, bool)

LoadOrStore is a function that atomically checks for the existence of a givne key within the map and adds the given value if the key was not found. The existing value is returned in the case that the key was found in the map, or the new value is returned in the case that the key was not found within the map. The returned boolean is true when the given key was found within the map.

type Bag

type Bag[T any] struct {
	// contains filtered or unexported fields
}

Bag is a type that holds values of T. Values can be added to the Bag and enumerated. However values can not be indexed or removed from the bag. The methods on Bag are thread safe. A zero value Bag can be used without initialization.

func (*Bag[T]) Add

func (b *Bag[T]) Add(v ...T)

Add adds the provided values to the Bag.

func (*Bag[T]) Seq

func (b *Bag[T]) Seq() iter.Seq[T]

Seq returns an iter.Seq[T] containing all of the values currently in the Bag in LIFO order. All values will be removed from the bag.

Jump to

Keyboard shortcuts

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