syncmap

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

VERY slim wrapper around sync.Map with Go generics for that sweet sweet type safety

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComparableMap

type ComparableMap[K comparable, V comparable] struct {
	Map[K, V]
}

func ComparableFromRegularMap

func ComparableFromRegularMap[K comparable, V comparable](m map[K]V) *ComparableMap[K, V]

func (*ComparableMap[K, V]) CompareAndDelete

func (m *ComparableMap[K, V]) CompareAndDelete(key K, old V) bool

func (*ComparableMap[K, V]) CompareAndSwap

func (m *ComparableMap[K, V]) CompareAndSwap(key K, old V, new V) bool

type Map

type Map[K comparable, V any] struct {
	InnerMap     sync.Map
	DefaultValue V
}

func FromRegularMap

func FromRegularMap[K comparable, V any](m map[K]V) *Map[K, V]

func (*Map[K, V]) Clear

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

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(key K)

func (*Map[K, V]) Items

func (m *Map[K, V]) Items() iter.Seq2[K, V]

func (*Map[K, V]) Length

func (m *Map[K, V]) Length() int

func (*Map[K, V]) Load

func (m *Map[K, V]) Load(key K) (value V, loaded bool)

func (*Map[K, V]) LoadAndDelete

func (m *Map[K, V]) LoadAndDelete(key K) (value V, loaded bool)

func (*Map[K, V]) LoadOrStore

func (m *Map[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(f func(key K, value V) bool)

func (*Map[K, V]) Store

func (m *Map[K, V]) Store(key K, value V)

func (*Map[K, V]) Swap

func (m *Map[K, V]) Swap(key K, value V) (previous V, loaded bool)

func (*Map[K, V]) ToRegularMap

func (m *Map[K, V]) ToRegularMap() map[K]V

Jump to

Keyboard shortcuts

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