Documentation
¶
Overview ¶
Package nummap provides maps of arbitrary keys to numeric values that can be accessed concurrently and read-edit-written atomically.
Index ¶
- type NumMap
- func (cm *NumMap[K, V]) Add(key K, value V) V
- func (cm *NumMap[K, V]) Apply(key K, f func(v V) V) (before, after V)
- func (cm *NumMap[K, V]) Delete(key K)
- func (cm *NumMap[K, V]) Get(k K) V
- func (cm *NumMap[K, V]) Len() int
- func (cm *NumMap[K, V]) Set(k K, v V)
- func (cm *NumMap[K, V]) Snapshot() map[K]V
- func (cm *NumMap[K, V]) Sub(key K, value V) V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NumMap ¶
type NumMap[K comparable, V oil.Number] struct { // contains filtered or unexported fields }
NumMap maps any type of key to any type of number and allows to manipulate those numbers in a concurrency safe fashion.
func NewNumMap ¶
func NewNumMap[K comparable, V oil.Number]() *NumMap[K, V]
NewNumMap creates a NumMap.
func (*NumMap[K, V]) Add ¶
func (cm *NumMap[K, V]) Add(key K, value V) V
Add adds a value to an entry of the map and returns the result.
func (*NumMap[K, V]) Apply ¶
func (cm *NumMap[K, V]) Apply(key K, f func(v V) V) (before, after V)
Apply applies an arbitrary function to an entry of the map and returns the result and the initial value.
func (*NumMap[K, V]) Delete ¶
func (cm *NumMap[K, V]) Delete(key K)
Delete deletes an entry from the NumMap.
func (*NumMap[K, V]) Set ¶
func (cm *NumMap[K, V]) Set(k K, v V)
Set sets an entry of the map to a value.
Click to show internal directories.
Click to hide internal directories.