mapx

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Keys added in v0.0.28

func Keys[K comparable, V any](m Map[K, V]) []K

func Len added in v0.0.28

func Len[K comparable, V any](m Map[K, V]) int

func Values added in v0.0.28

func Values[K comparable, V any](m Map[K, V]) []V

Types

type Map added in v0.0.28

type Map[K comparable, V any] interface {
	Exists(K) bool
	Load(K) (V, bool)
	LoadEq(func(any) bool) (V, bool)
	LoadEqs(func(any) bool) []V
	BatchLoad(...K) []Result[V]
	Store(K, V)
	BatchStore([]K, []V)
	LoadOrStore(K, V) (actual V, loaded bool)
	LoadAndDelete(K) (value V, loaded bool)
	Delete(K)
	BatchDelete(...K)
	Swap(K, V) (previous V, loaded bool)
	CompareAndSwap(key K, old, new V) (swapped bool)
	CompareAndDelete(key K, old V) (deleted bool)
	Range(func(key K, value V) (shouldContinue bool))
	Clear()
}

func NewSmap added in v0.0.28

func NewSmap(m *sync.Map) Map[any, any]

func NewXmap added in v0.0.28

func NewXmap[K comparable, V any](m map[K]V, safe bool) Map[K, V]

type Result added in v0.0.28

type Result[V any] struct {
	V      V
	Loaded bool
}

type U added in v0.0.28

type U[K comparable, V any] interface {
	xmap[K, V] | *sync.Map
}

Jump to

Keyboard shortcuts

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