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]) 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]) Get(key K) (result V, present bool)
- func (om *OrderedMap[K, V]) GetPair(key K) *Pair[K, V]
- 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)
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶ added in v0.26.0
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 ¶ added in v0.25.0
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedMap
func (*OrderedMap[K, V]) Clear ¶ added in v0.25.0
func (om *OrderedMap[K, V]) Clear()
Clear removes all entries from this ordered map.
func (*OrderedMap[K, V]) Contains ¶ added in v0.28.0
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 ¶ added in v0.25.0
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]) Foreach ¶ added in v0.25.0
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 ¶ added in v0.25.0
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]) Get ¶ added in v0.25.0
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 ¶ added in v0.25.0
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]) Len ¶ added in v0.25.0
func (om *OrderedMap[K, V]) Len() int
Len returns the length of the ordered map.
func (*OrderedMap[K, V]) Newest ¶ added in v0.25.0
func (om *OrderedMap[K, V]) Newest() *Pair[K, V]
Newest returns a pointer to the newest pair.
func (*OrderedMap[K, V]) Oldest ¶ added in v0.25.0
func (om *OrderedMap[K, V]) Oldest() *Pair[K, V]
Oldest returns a pointer to the oldest pair.
func (*OrderedMap[K, V]) Set ¶ added in v0.25.0
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`.