Documentation
¶
Index ¶
- type ConcurrentMap
- func (cf *ConcurrentMap[K, V]) AddAll(entries map[K]V)
- func (cf *ConcurrentMap[K, V]) Compute(k K, computeFunc func(k K, v V) (val V, ok bool))
- func (cf *ConcurrentMap[K, V]) Delete(k K) (v V, existed bool)
- func (cf *ConcurrentMap[K, V]) Each(f func(k K, v V) (stop bool))
- func (cf *ConcurrentMap[K, V]) Entries() []MapEntry[K, V]
- func (cf *ConcurrentMap[K, V]) Get(k K) (v V, ok bool)
- func (cf *ConcurrentMap[K, V]) Keys() []K
- func (cf *ConcurrentMap[K, V]) Len() int
- func (cf *ConcurrentMap[K, V]) Set(k K, v V)
- func (cf *ConcurrentMap[K, V]) Values() []V
- type MapEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentMap ¶
type ConcurrentMap[K comparable, V any] struct { // contains filtered or unexported fields }
func (*ConcurrentMap[K, V]) AddAll ¶
func (cf *ConcurrentMap[K, V]) AddAll(entries map[K]V)
func (*ConcurrentMap[K, V]) Compute ¶
func (cf *ConcurrentMap[K, V]) Compute(k K, computeFunc func(k K, v V) (val V, ok bool))
Compute sets the value of key 'k' to the result of the supplied computeFunc. If the value of 'ok' is 'false', the entry for key 'k' will be removed from the ConcurrentMap.
func (*ConcurrentMap[K, V]) Delete ¶
func (cf *ConcurrentMap[K, V]) Delete(k K) (v V, existed bool)
func (*ConcurrentMap[K, V]) Each ¶
func (cf *ConcurrentMap[K, V]) Each(f func(k K, v V) (stop bool))
Each executes `f` for each key-value pair in the map, while holding the lock. ! Avoid doing expensive operations in `f`, instead create a copy (eg via `Entries()`).
func (*ConcurrentMap[K, V]) Entries ¶
func (cf *ConcurrentMap[K, V]) Entries() []MapEntry[K, V]
func (*ConcurrentMap[K, V]) Get ¶
func (cf *ConcurrentMap[K, V]) Get(k K) (v V, ok bool)
func (*ConcurrentMap[K, V]) Keys ¶
func (cf *ConcurrentMap[K, V]) Keys() []K
func (*ConcurrentMap[K, V]) Len ¶
func (cf *ConcurrentMap[K, V]) Len() int
func (*ConcurrentMap[K, V]) Set ¶
func (cf *ConcurrentMap[K, V]) Set(k K, v V)
func (*ConcurrentMap[K, V]) Values ¶
func (cf *ConcurrentMap[K, V]) Values() []V
type MapEntry ¶
type MapEntry[K comparable, V any] struct { Key K Value V }
Click to show internal directories.
Click to hide internal directories.