safe

package
v0.0.0-...-200cf31 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 2 Imported by: 0

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