Documentation
¶
Overview ¶
A typed, thread-safe map built on top of sync.Map, using generics.
Index ¶
- type SyncMap
- func (sm *SyncMap[K, V]) Delete(key K)
- func (sm *SyncMap[K, V]) Keys() []K
- func (sm *SyncMap[K, V]) Len() int
- func (sm *SyncMap[K, V]) Load(key K) (V, bool)
- func (sm *SyncMap[K, V]) LoadOrStore(key K, value V) (V, bool)
- func (sm *SyncMap[K, V]) Range(fn func(key K, value V) bool)
- func (sm *SyncMap[K, V]) Store(key K, value V)
- func (sm *SyncMap[K, V]) Values() []V
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 { // contains filtered or unexported fields }
SyncMap provides a thread-safe generic map built on top of sync.Map.
func NewSyncMap ¶
func NewSyncMap[K comparable, V any]() *SyncMap[K, V]
NewSyncMap creates a new thread-safe generic map
func (*SyncMap[K, V]) LoadOrStore ¶
LoadOrStore gets existing value or stores new one, returns actual value and whether it was loaded
func (*SyncMap[K, V]) Range ¶
Range calls fn for each key-value pair. Returning false quits the iteration
Click to show internal directories.
Click to hide internal directories.