Documentation ¶
Index ¶
- type Element
- type OrderedMap
- func (o *OrderedMap[K, V]) Clear()
- func (o *OrderedMap[K, V]) Clone() (cloned *OrderedMap[K, V])
- func (o *OrderedMap[K, V]) Decode(b []byte) (bytesRead int, err error)
- func (o *OrderedMap[K, V]) Delete(key K) bool
- func (o *OrderedMap[K, V]) Encode() ([]byte, error)
- func (o *OrderedMap[K, V]) ForEach(consumer func(key K, value V) bool) bool
- func (o *OrderedMap[K, V]) ForEachReverse(consumer func(key K, value V) bool) bool
- func (o *OrderedMap[K, V]) Get(key K) (value V, exists bool)
- func (o *OrderedMap[K, V]) Has(key K) (has bool)
- func (o *OrderedMap[K, V]) Head() (key K, value V, exists bool)
- func (o *OrderedMap[K, V]) Initialize()
- func (o *OrderedMap[K, V]) IsEmpty() bool
- func (o *OrderedMap[K, V]) Set(key K, newValue V) (previousValue V, previousValueExisted bool)
- func (o *OrderedMap[K, V]) Size() int
- func (o *OrderedMap[K, V]) Tail() (key K, value V, exists bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element[K comparable, V any] struct { // contains filtered or unexported fields }
Element defines the model of each element of the orderedMap.
type OrderedMap ¶
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedMap provides a concurrent-safe ordered map.
func (*OrderedMap[K, V]) Clear ¶
func (o *OrderedMap[K, V]) Clear()
Clear removes all elements from the OrderedMap.
func (*OrderedMap[K, V]) Clone ¶
func (o *OrderedMap[K, V]) Clone() (cloned *OrderedMap[K, V])
Clone returns a copy of the orderedMap.
func (*OrderedMap[K, V]) Decode ¶
func (o *OrderedMap[K, V]) Decode(b []byte) (bytesRead int, err error)
Decode deserializes bytes into a valid object.
func (*OrderedMap[K, V]) Delete ¶
func (o *OrderedMap[K, V]) Delete(key K) bool
Delete deletes the given key (and related value) from the orderedMap. It returns false if the key is not found.
func (*OrderedMap[K, V]) Encode ¶
func (o *OrderedMap[K, V]) Encode() ([]byte, error)
Encode returns a serialized byte slice of the object.
func (*OrderedMap[K, V]) ForEach ¶
func (o *OrderedMap[K, V]) ForEach(consumer func(key K, value V) bool) bool
ForEach iterates through the orderedMap and calls the consumer function for every element. The iteration can be aborted by returning false in the consumer.
func (*OrderedMap[K, V]) ForEachReverse ¶
func (o *OrderedMap[K, V]) ForEachReverse(consumer func(key K, value V) bool) bool
ForEachReverse iterates through the orderedMap in reverse order and calls the consumer function for every element. The iteration can be aborted by returning false in the consumer.
func (*OrderedMap[K, V]) Get ¶
func (o *OrderedMap[K, V]) Get(key K) (value V, exists bool)
Get returns the value mapped to the given key if exists.
func (*OrderedMap[K, V]) Has ¶
func (o *OrderedMap[K, V]) Has(key K) (has bool)
Has returns if an entry with the given key exists.
func (*OrderedMap[K, V]) Head ¶
func (o *OrderedMap[K, V]) Head() (key K, value V, exists bool)
Head returns the first map entry.
func (*OrderedMap[K, V]) Initialize ¶
func (o *OrderedMap[K, V]) Initialize()
Initialize returns the first map entry.
func (*OrderedMap[K, V]) IsEmpty ¶
func (o *OrderedMap[K, V]) IsEmpty() bool
IsEmpty returns a boolean value indicating whether the map empty.
func (*OrderedMap[K, V]) Set ¶
func (o *OrderedMap[K, V]) Set(key K, newValue V) (previousValue V, previousValueExisted bool)
Set adds a key-value pair to the orderedMap.
func (*OrderedMap[K, V]) Size ¶
func (o *OrderedMap[K, V]) Size() int
Size returns the size of the orderedMap.
func (*OrderedMap[K, V]) Tail ¶
func (o *OrderedMap[K, V]) Tail() (key K, value V, exists bool)
Tail returns the last map entry.