Documentation
¶
Index ¶
- func New[T OrderedMap[K, V], K comparable, V any](size int) *T
- type OrderedMap
- func (om *OrderedMap[K, V]) Clear()
- func (om *OrderedMap[K, V]) Contains(key K) (present bool)
- func (om *OrderedMap[K, V]) Delete(key K) (oldValue V, present bool)
- func (om *OrderedMap[K, V]) ForAllKeys(predicate func(key K) bool) bool
- func (om *OrderedMap[K, V]) ForAnyKey(predicate func(key K) bool) bool
- func (om *OrderedMap[K, V]) Foreach(f func(key K, value V))
- func (om *OrderedMap[K, V]) ForeachWithError(f func(key K, value V) error) error
- func (om *OrderedMap[K, V]) ForeachWithIndex(f func(index int, key K, value V))
- func (om *OrderedMap[K, V]) Get(key K) (result V, present bool)
- func (om *OrderedMap[K, V]) GetPair(key K) *Pair[K, V]
- func (om *OrderedMap[K, V]) KeySetIsDisjointFrom(other *OrderedMap[K, V]) bool
- func (om *OrderedMap[K, V]) Len() int
- func (om *OrderedMap[K, V]) Newest() *Pair[K, V]
- func (om *OrderedMap[K, V]) Oldest() *Pair[K, V]
- func (om *OrderedMap[K, V]) Set(key K, value V) (oldValue V, present bool)
- func (om *OrderedMap[K, V]) SetAll(other *OrderedMap[K, V])
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New[T OrderedMap[K, V], K comparable, V any](size int) *T
New returns a new OrderedMap of the given size
Types ¶
type OrderedMap ¶
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedMap
func KeySetIntersection ¶
func KeySetIntersection[K comparable, V any](om *OrderedMap[K, V], other *OrderedMap[K, V]) *OrderedMap[K, V]
KeySetIntersection returns a map containing the intersection of the keys in the two maps this is only well defined for sets (i.e. maps without meaningful values)
func KeySetUnion ¶
func KeySetUnion[K comparable, V any](om *OrderedMap[K, V], other *OrderedMap[K, V]) *OrderedMap[K, V]
KeySetUnion returns a map containing the union of the keys in the two maps this is only well defined for sets (i.e. maps without meaningful values)
func (*OrderedMap[K, V]) Clear ¶
func (om *OrderedMap[K, V]) Clear()
Clear removes all entries from this ordered map.
func (*OrderedMap[K, V]) Contains ¶
func (om *OrderedMap[K, V]) Contains(key K) (present bool)
Contains returns true if the key is present in the map and false otherwise.
func (*OrderedMap[K, V]) Delete ¶
func (om *OrderedMap[K, V]) Delete(key K) (oldValue V, present bool)
Delete removes the key-value pair, and returns what `Get` would have returned on that key prior to the call to `Delete`.
func (*OrderedMap[K, V]) ForAllKeys ¶
func (om *OrderedMap[K, V]) ForAllKeys(predicate func(key K) bool) bool
ForAllKeys iterates over the keys of the map, and returns whether the provided predicate is true for all of them
func (*OrderedMap[K, V]) ForAnyKey ¶
func (om *OrderedMap[K, V]) ForAnyKey(predicate func(key K) bool) bool
ForAnyKey iterates over the keys of the map, and returns whether the provided predicate is true for any of them
func (*OrderedMap[K, V]) Foreach ¶
func (om *OrderedMap[K, V]) Foreach(f func(key K, value V))
Foreach iterates over the entries of the map in the insertion order, and invokes the provided function for each key-value pair.
func (*OrderedMap[K, V]) ForeachWithError ¶
func (om *OrderedMap[K, V]) ForeachWithError(f func(key K, value V) error) error
ForeachWithError iterates over the entries of the map in the insertion order, and invokes the provided function for each key-value pair. If the passed function returns an error, iteration breaks and the error is returned.
func (*OrderedMap[K, V]) ForeachWithIndex ¶
func (om *OrderedMap[K, V]) ForeachWithIndex(f func(index int, key K, value V))
ForeachWithIndex iterates over the entries of the map in the insertion order, and invokes the provided function for each key-value pair.
func (*OrderedMap[K, V]) Get ¶
func (om *OrderedMap[K, V]) Get(key K) (result V, present bool)
Get returns the value associated with the given key. Returns nil if not found. The second return value indicates if the key is present in the map.
func (*OrderedMap[K, V]) GetPair ¶
func (om *OrderedMap[K, V]) GetPair(key K) *Pair[K, V]
GetPair returns the key-value pair associated with the given key. Returns nil if not found.
func (*OrderedMap[K, V]) KeySetIsDisjointFrom ¶
func (om *OrderedMap[K, V]) KeySetIsDisjointFrom(other *OrderedMap[K, V]) bool
KeySetIsDisjointFrom checks whether the key set of the receiver is disjoint from of the argument map's key set
func (*OrderedMap[K, V]) Len ¶
func (om *OrderedMap[K, V]) Len() int
Len returns the length of the ordered map.
func (*OrderedMap[K, V]) Newest ¶
func (om *OrderedMap[K, V]) Newest() *Pair[K, V]
Newest returns a pointer to the newest pair.
func (*OrderedMap[K, V]) Oldest ¶
func (om *OrderedMap[K, V]) Oldest() *Pair[K, V]
Oldest returns a pointer to the oldest pair.
func (*OrderedMap[K, V]) Set ¶
func (om *OrderedMap[K, V]) Set(key K, value V) (oldValue V, present bool)
Set sets the key-value pair, and returns what `Get` would have returned on that key prior to the call to `Set`.
func (*OrderedMap[K, V]) SetAll ¶
func (om *OrderedMap[K, V]) SetAll(other *OrderedMap[K, V])
SetAll sets all the values in the input map in the receiver map, overrwriting any previous entries