Documentation ¶
Index ¶
- func StringComparator(s1 string, s2 string) bool
- type SyncSet
- type TypedNestedSyncMap
- func (m *TypedNestedSyncMap[K1, K2, V]) DeepApply(toApply func(V))
- func (m *TypedNestedSyncMap[K1, K2, V]) DeepCopy(copier func(V) V) *TypedNestedSyncMap[K1, K2, V]
- func (m *TypedNestedSyncMap[K1, K2, V]) DeleteNested(key1 K1, key2 K2)
- func (m *TypedNestedSyncMap[K1, K2, V]) LoadNested(key1 K1, key2 K2) (value V, ok bool)
- func (m *TypedNestedSyncMap[K1, K2, V]) LoadOrStoreNested(key1 K1, key2 K2, value V) (actual V, loaded bool)
- func (m *TypedNestedSyncMap[K1, K2, V]) StoreNested(key1 K1, key2 K2, value V)
- type TypedSyncMap
- func (m *TypedSyncMap[K, V]) DeepApply(toApply func(V))
- func (m *TypedSyncMap[K, V]) DeepCopy(copier func(V) V) *TypedSyncMap[K, V]
- func (m *TypedSyncMap[K, V]) Delete(key K)
- func (m *TypedSyncMap[K, V]) Len() int
- func (m *TypedSyncMap[K, V]) Load(key K) (value V, ok bool)
- func (m *TypedSyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
- func (m *TypedSyncMap[K, V]) Range(f func(K, V) bool)
- func (m *TypedSyncMap[K, V]) Store(key K, value V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringComparator ¶
Types ¶
type SyncSet ¶
type SyncSet[T comparable] struct { // contains filtered or unexported fields }
A set-like data structure that is guaranteed to be data race free during write operations. It can return internal data as a slice with a comparator provided, so that the resulting slice has a deterministic ordering.
func NewSyncSet ¶
func NewSyncSet[T comparable](initial []T) SyncSet[T]
func (*SyncSet[T]) ToOrderedSlice ¶
type TypedNestedSyncMap ¶
type TypedNestedSyncMap[K1 constraints.Ordered, K2 constraints.Ordered, V any] struct { *TypedSyncMap[K1, *TypedSyncMap[K2, V]] // contains filtered or unexported fields }
A nested map data structure that is guaranteed to be data race free during write operations. It is the synchronous equivalent of type map[K1]map[K2]V. Besides `sync.Map`'s existing interfaces, it also provides convenient methods to read/write nested values directly. For example, to set value `v` for outer key `k1` and inner key `k2`, one can simply call StoreNested(k1, k2, v), without worrying about creating the inner map if it doesn't exist.
func NewTypedNestedSyncMap ¶
func NewTypedNestedSyncMap[K1 constraints.Ordered, K2 constraints.Ordered, V any]() *TypedNestedSyncMap[K1, K2, V]
func (*TypedNestedSyncMap[K1, K2, V]) DeepApply ¶
func (m *TypedNestedSyncMap[K1, K2, V]) DeepApply(toApply func(V))
func (*TypedNestedSyncMap[K1, K2, V]) DeepCopy ¶
func (m *TypedNestedSyncMap[K1, K2, V]) DeepCopy(copier func(V) V) *TypedNestedSyncMap[K1, K2, V]
func (*TypedNestedSyncMap[K1, K2, V]) DeleteNested ¶
func (m *TypedNestedSyncMap[K1, K2, V]) DeleteNested(key1 K1, key2 K2)
func (*TypedNestedSyncMap[K1, K2, V]) LoadNested ¶
func (m *TypedNestedSyncMap[K1, K2, V]) LoadNested(key1 K1, key2 K2) (value V, ok bool)
func (*TypedNestedSyncMap[K1, K2, V]) LoadOrStoreNested ¶
func (m *TypedNestedSyncMap[K1, K2, V]) LoadOrStoreNested(key1 K1, key2 K2, value V) (actual V, loaded bool)
func (*TypedNestedSyncMap[K1, K2, V]) StoreNested ¶
func (m *TypedNestedSyncMap[K1, K2, V]) StoreNested(key1 K1, key2 K2, value V)
type TypedSyncMap ¶
type TypedSyncMap[K constraints.Ordered, V any] struct { // contains filtered or unexported fields }
A map-like data structure that is guaranteed to be data race free during write operations. It is a typed wrapper over the builtin typeless `sync.Map`. The CRUD interface is exactly the same as those of `sync.Map`.
func NewTypedSyncMap ¶
func NewTypedSyncMap[K constraints.Ordered, V any]() *TypedSyncMap[K, V]
func (*TypedSyncMap[K, V]) DeepApply ¶
func (m *TypedSyncMap[K, V]) DeepApply(toApply func(V))
func (*TypedSyncMap[K, V]) DeepCopy ¶
func (m *TypedSyncMap[K, V]) DeepCopy(copier func(V) V) *TypedSyncMap[K, V]
func (*TypedSyncMap[K, V]) Delete ¶
func (m *TypedSyncMap[K, V]) Delete(key K)
func (*TypedSyncMap[K, V]) Len ¶
func (m *TypedSyncMap[K, V]) Len() int
func (*TypedSyncMap[K, V]) Load ¶
func (m *TypedSyncMap[K, V]) Load(key K) (value V, ok bool)
func (*TypedSyncMap[K, V]) LoadOrStore ¶
func (m *TypedSyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
func (*TypedSyncMap[K, V]) Range ¶
func (m *TypedSyncMap[K, V]) Range(f func(K, V) bool)
func (*TypedSyncMap[K, V]) Store ¶
func (m *TypedSyncMap[K, V]) Store(key K, value V)