Documentation
¶
Overview ¶
Package hatmap provides generic goroutine-safe map. It is implemented as an ordinary map protected by mutex ("mutex hat" idiom).
Index ¶
- type Condition
- type Map
- func (m *Map[K, V]) All() iter.Seq2[K, V]
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Delete(key K)
- func (m *Map[K, V]) DeleteIf(key K, cond Condition[V]) bool
- func (m *Map[K, V]) Get(key K) (V, bool)
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) SetIf(key K, newValue V, cond Condition[V]) (actual V, ok bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Condition ¶
Condition to operate on a current value by the given key. May be called multiple times.
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a goroutine-safe map.
Map must not be copied after first use.
func (*Map[K, V]) Delete ¶
func (m *Map[K, V]) Delete(key K)
Delete deletes the value by the given key. If the key doesn't exist does nothing.
func (*Map[K, V]) DeleteIf ¶
DeleteIf conditionally deletes the value by the given key. Returns true if the value was deleted.
Click to show internal directories.
Click to hide internal directories.