Documentation ¶
Index ¶
- type SyncMap
- func (m *SyncMap[K, V]) Clear()
- func (m *SyncMap[K, V]) Clone() map[K]V
- func (m *SyncMap[K, V]) Delete(k K)
- func (m *SyncMap[K, V]) Len() int
- func (m *SyncMap[K, V]) Load(k K) (v V, ok bool)
- func (m *SyncMap[K, V]) LoadAndDelete(k K) (v V, loaded bool)
- func (m *SyncMap[K, V]) LoadOrStore(k K, v V) (actual V, loaded bool)
- func (m *SyncMap[K, V]) Range(f func(k K, v V) bool)
- func (m *SyncMap[K, V]) Store(k K, v 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 { 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]) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, and returns the previous value if any.
func (*SyncMap[K, V]) LoadOrStore ¶
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value.
Click to show internal directories.
Click to hide internal directories.