Documentation ¶
Index ¶
- type Iterator
- func (it Iterator[K, V]) Get() misc.Pair[K, V]
- func (it Iterator[K, V]) Key() K
- func (it Iterator[K, V]) Move()
- func (it Iterator[K, V]) Remove()
- func (it Iterator[K, V]) SetValue(value V)
- func (it Iterator[K, V]) Valid() bool
- func (it Iterator[K, V]) Value() V
- func (it Iterator[K, V]) ValueRef() *V
- type Wrapper
- func (w *Wrapper[K, V]) Clear()
- func (w *Wrapper[K, V]) Clone() maps.Map[K, V]
- func (w *Wrapper[K, V]) Contains(key K) bool
- func (w *Wrapper[K, V]) Get(key K) V
- func (w *Wrapper[K, V]) GetRef(key K) *V
- func (w *Wrapper[K, V]) Iterator() iter.Iterator[misc.Pair[K, V]]
- func (w *Wrapper[K, V]) MapIterator() maps.Iterator[K, V]
- func (w *Wrapper[K, V]) RefsStream2(yield func(K, *V) bool)
- func (w *Wrapper[K, V]) Remove(key K)
- func (w *Wrapper[K, V]) Set(key K, value V)
- func (w *Wrapper[K, V]) Size() int
- func (w *Wrapper[K, V]) Stream2(yield func(K, V) bool)
- func (w *Wrapper[K, V]) Transaction(updateFunction func(m maps.Map[K, V]))
- func (w *Wrapper[K, V]) TryGet(key K) (V, bool)
- func (w *Wrapper[K, V]) Update(key K, updateFunction func(oldValue V) V)
- func (w *Wrapper[K, V]) UpdateRef(key K, updateFunction func(oldValue *V))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator[K, V any] struct { // contains filtered or unexported fields }
Iterator is a wrapper around an map iterator that provides thread-safe access to the underlying map.
func (Iterator[K, V]) Move ¶
func (it Iterator[K, V]) Move()
Move moves the iterator to the next entry.
func (Iterator[K, V]) SetValue ¶
func (it Iterator[K, V]) SetValue(value V)
SetValue sets the current entry's value.
func (Iterator[K, V]) Valid ¶
Valid returns true if the iterator is currently pointing to a valid entry.
type Wrapper ¶
type Wrapper[K, V any] struct { // contains filtered or unexported fields }
Wrapper is a wrapper around a map that provides thread-safe access to the map. Locking is done through read-write mutex. This means that multiple goroutines can read from the map at the same time, but only one goroutine can write to the map at the same time.
func (*Wrapper[K, V]) Clear ¶
func (w *Wrapper[K, V]) Clear()
Clear removes all entries from the map.
func (*Wrapper[K, V]) Get ¶
func (w *Wrapper[K, V]) Get(key K) V
Get returns the value associated with the given key.
func (*Wrapper[K, V]) GetRef ¶
func (w *Wrapper[K, V]) GetRef(key K) *V
GetRef returns a reference to the value associated with the given key. Usage of this method is discouraged, as it breaks the thread-safety of the map. Lock will not be held while the reference is used, so it is possible that the value of the element changes while the reference is used.
func (*Wrapper[K, V]) MapIterator ¶
MapIterator returns an iterator over the map.
func (*Wrapper[K, V]) RefsStream2 ¶ added in v1.7.0
RefsStream2 streams over the keys and references to the values in the Map.
func (*Wrapper[K, V]) Remove ¶
func (w *Wrapper[K, V]) Remove(key K)
Remove removes the entry with the given key.
func (*Wrapper[K, V]) Set ¶
func (w *Wrapper[K, V]) Set(key K, value V)
Set sets the value associated with the given key.
func (*Wrapper[K, V]) Transaction ¶
Transaction executes the given function with the map as an argument. The map is locked for writing while the function is executed.
func (*Wrapper[K, V]) TryGet ¶
TryGet returns the value associated with the given key, and true if the key exists. If the key does not exist, the default value for the value type is returned, and false is returned.