Documentation ¶
Index ¶
- type RandomMap
- func (rmap *RandomMap[K, V]) Delete(key K) (result V, exists bool)
- func (rmap *RandomMap[K, V]) ForEach(consumer func(key K, value V))
- func (rmap *RandomMap[K, V]) Get(key K) (result V, exists bool)
- func (rmap *RandomMap[K, V]) Keys() (result []K)
- func (rmap *RandomMap[K, V]) RandomEntry() (result V, exists bool)
- func (rmap *RandomMap[K, V]) RandomKey() (result K, exists bool)
- func (rmap *RandomMap[K, V]) RandomUniqueEntries(count int) (results []V)
- func (rmap *RandomMap[K, V]) Set(key K, value V) (updated bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RandomMap ¶
type RandomMap[K comparable, V any] struct { *randommap.RandomMap }
RandomMap defines a map with extended ability to return a random entry.
func (*RandomMap[K, V]) ForEach ¶
func (rmap *RandomMap[K, V]) ForEach(consumer func(key K, value V))
ForEach iterates through the elements in the map and calls the consumer function for each element.
func (*RandomMap[K, V]) Keys ¶
func (rmap *RandomMap[K, V]) Keys() (result []K)
Keys returns the list of keys stored in the RandomMap.
func (*RandomMap[K, V]) RandomEntry ¶
RandomEntry returns a random value from the map.
func (*RandomMap[K, V]) RandomUniqueEntries ¶
RandomUniqueEntries returns n random and unique values from the map. When count is equal or bigger than the size of the random map, the every entry in the map is returned.
Click to show internal directories.
Click to hide internal directories.