Documentation ¶
Overview ¶
Package orderedmap provides an implementation of ordered map structure in Go. In this map, keys are maintained in an order.
Index ¶
- Variables
- type OrderedMap
- func (om *OrderedMap[K, V]) Back() (K, V)
- func (om *OrderedMap[K, V]) Delete(key K) (val V, present bool)
- func (om *OrderedMap[K, V]) Front() (K, V)
- func (om *OrderedMap[K, V]) Get(key K) (value V, found bool)
- func (om *OrderedMap[K, V]) Len() int
- func (om *OrderedMap[K, V]) MoveAfter(key, markedKey K) error
- func (om *OrderedMap[K, V]) MoveBefore(key, markedKey K) error
- func (om *OrderedMap[K, V]) MoveToBack(key K) error
- func (om *OrderedMap[K, V]) MoveToFront(key K) error
- func (om *OrderedMap[K, V]) ReverseScan(itor func(key K, val V) bool)
- func (om *OrderedMap[K, V]) Scan(itor func(key K, val V) bool)
- func (om *OrderedMap[K, V]) Set(key K, value V) (oldVal V, replaced bool)
- type Pair
Constants ¶
This section is empty.
Variables ¶
var ErrKeyNotFound = errors.New("orderedmap: key not found")
ErrKeyNotFound means the key couldn't be found in the map.
Functions ¶
This section is empty.
Types ¶
type OrderedMap ¶
OrderedMap is an implementation of ordered map. It should be initialized with New function.
func (*OrderedMap[K, V]) Back ¶
func (om *OrderedMap[K, V]) Back() (K, V)
Back returns the pair of key and value at the back of the list.
func (*OrderedMap[K, V]) Delete ¶
func (om *OrderedMap[K, V]) Delete(key K) (val V, present bool)
Delete deletes a key. It returns the deleted value.
func (*OrderedMap[K, V]) Front ¶
func (om *OrderedMap[K, V]) Front() (K, V)
Front returns the pair of key and value at the front of the list.
func (*OrderedMap[K, V]) Get ¶
func (om *OrderedMap[K, V]) Get(key K) (value V, found bool)
Get returns the value for the provided key and whether the key presents in the map or not.
func (*OrderedMap[K, V]) Len ¶
func (om *OrderedMap[K, V]) Len() int
Len returns the size of the map.
func (*OrderedMap[K, V]) MoveAfter ¶
func (om *OrderedMap[K, V]) MoveAfter(key, markedKey K) error
MoveAfter moves key to a new position after markedKey.
func (*OrderedMap[K, V]) MoveBefore ¶
func (om *OrderedMap[K, V]) MoveBefore(key, markedKey K) error
MoveAfter moves key to a new position after markedKey.
func (*OrderedMap[K, V]) MoveToBack ¶
func (om *OrderedMap[K, V]) MoveToBack(key K) error
MoveToBack moves key to the front of list.
func (*OrderedMap[K, V]) MoveToFront ¶
func (om *OrderedMap[K, V]) MoveToFront(key K) error
MoveToFront moves key to the front of list.
func (*OrderedMap[K, V]) ReverseScan ¶
func (om *OrderedMap[K, V]) ReverseScan(itor func(key K, val V) bool)
ReverseScan scans through the map in in the reverse of the stored order.
func (*OrderedMap[K, V]) Scan ¶
func (om *OrderedMap[K, V]) Scan(itor func(key K, val V) bool)
Scan scans through the map in in the stored order.
func (*OrderedMap[K, V]) Set ¶
func (om *OrderedMap[K, V]) Set(key K, value V) (oldVal V, replaced bool)
Set inserts a new key, value into the map or replaces it if the key presents in the map.