safe

package
v0.6401.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 2 Imported by: 0 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SyncMap

type SyncMap[K comparable, V any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SyncMap is a thread-safe map

func NewSyncMap

func NewSyncMap[K comparable, V any]() *SyncMap[K, V]

NewSyncMap creates a new thread-safe map

func (*SyncMap[K, V]) Clear

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

func (*SyncMap[K, V]) Clone

func (m *SyncMap[K, V]) Clone() map[K]V

func (*SyncMap[K, V]) Delete

func (m *SyncMap[K, V]) Delete(k K)

func (*SyncMap[K, V]) Len

func (m *SyncMap[K, V]) Len() int

func (*SyncMap[K, V]) Load

func (m *SyncMap[K, V]) Load(k K) (v V, ok bool)

func (*SyncMap[K, V]) LoadAndDelete

func (m *SyncMap[K, V]) LoadAndDelete(k K) (v V, loaded bool)

LoadAndDelete deletes the value for a key, and returns the previous value if any.

func (*SyncMap[K, V]) LoadOrStore

func (m *SyncMap[K, V]) LoadOrStore(k K, v V) (actual V, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value.

func (*SyncMap[K, V]) Range

func (m *SyncMap[K, V]) Range(f func(k K, v V) bool)

func (*SyncMap[K, V]) Store

func (m *SyncMap[K, V]) Store(k K, v V)

Jump to

Keyboard shortcuts

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