Documentation
¶
Index ¶
- type SafeMap
- func (m *SafeMap[K, V]) All() iter.Seq2[K, V]
- func (m *SafeMap[K, V]) Clear()
- func (m *SafeMap[K, V]) Delete(key K)
- func (m *SafeMap[K, V]) Get(key K) (V, bool)
- func (m *SafeMap[K, V]) Has(key K) bool
- func (m *SafeMap[K, V]) Keys() []K
- func (m *SafeMap[K, V]) Len() int
- func (m *SafeMap[K, V]) Range(f func(key K, value V) bool)
- func (m *SafeMap[K, V]) Set(key K, value V)
- func (m *SafeMap[K, V]) Update(key K, f func(V) V)
- func (m *SafeMap[K, V]) UpdateAndGet(key K, f func(V) V) V
- func (m *SafeMap[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SafeMap ¶
type SafeMap[K comparable, V any] struct { // contains filtered or unexported fields }
func NewSafeMap ¶
func NewSafeMap[K comparable, V any]() *SafeMap[K, V]
create a SafeMap instance without size (size=0)
func NewSafeMapWithSize ¶
func NewSafeMapWithSize[K comparable, V any](size int) *SafeMap[K, V]
create a SafeMap instance with size
func (*SafeMap[K, V]) All ¶
All returns a Go 1.23 compatible iterator (iter.Seq2). Note: A read-lock is held during the entire iteration. Calling write operations (e.g., Set, Delete, Update) on the same map inside the loop will cause a deadlock.
func (*SafeMap[K, V]) UpdateAndGet ¶
func (m *SafeMap[K, V]) UpdateAndGet(key K, f func(V) V) V
Click to show internal directories.
Click to hide internal directories.