Documentation
¶
Overview ¶
Package orderedmap is a Go implementation of Python's OrderedDict class, a map that preserves the order of insertion, so key:value pairs can be iterated in the order they where added. It can also be used as a stack (LIFO) or queue (FIFO).
Index ¶
- type MapIterator
- type OrderedMap
- func (om *OrderedMap) Delete(key interface{})
- func (om *OrderedMap) Get(key interface{}) (value interface{}, ok bool)
- func (om *OrderedMap) GetFirst() (key interface{}, value interface{}, ok bool)
- func (om *OrderedMap) GetLast() (key interface{}, value interface{}, ok bool)
- func (om *OrderedMap) Iter() *MapIterator
- func (om *OrderedMap) IterReverse() *MapIterator
- func (om *OrderedMap) Len() int
- func (om *OrderedMap) Move(key interface{}, last bool) (ok bool)
- func (om *OrderedMap) MoveFirst(key interface{}) (ok bool)
- func (om *OrderedMap) MoveLast(key interface{}) (ok bool)
- func (om *OrderedMap) Pop(last bool) (key interface{}, value interface{}, ok bool)
- func (om *OrderedMap) PopFirst() (key interface{}, value interface{}, ok bool)
- func (om *OrderedMap) PopLast() (key interface{}, value interface{}, ok bool)
- func (om *OrderedMap) Set(key interface{}, value interface{})
- func (om *OrderedMap) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MapIterator ¶
type MapIterator struct {
// contains filtered or unexported fields
}
MapIterator is a iterator over an OrderedMap
func (*MapIterator) Next ¶
func (mi *MapIterator) Next() (key interface{}, value interface{}, ok bool)
Next key:value pair
type OrderedMap ¶
type OrderedMap struct {
// contains filtered or unexported fields
}
OrderedMap class
func (*OrderedMap) Delete ¶
func (om *OrderedMap) Delete(key interface{})
Delete a key:value pair from the map.
func (*OrderedMap) Get ¶
func (om *OrderedMap) Get(key interface{}) (value interface{}, ok bool)
Get the value of an existing key, leaving the map unchanged
func (*OrderedMap) GetFirst ¶
func (om *OrderedMap) GetFirst() (key interface{}, value interface{}, ok bool)
GetFirst returns the key and value for the first element, leaving the map unchanged
func (*OrderedMap) GetLast ¶
func (om *OrderedMap) GetLast() (key interface{}, value interface{}, ok bool)
GetLast return the key and value for the last element added, leaving the map unchanged
func (*OrderedMap) IterReverse ¶
func (om *OrderedMap) IterReverse() *MapIterator
IterReverse creates a reverse order map iterator
func (*OrderedMap) Len ¶
func (om *OrderedMap) Len() int
Len returns the number of elements in the Map
func (*OrderedMap) Move ¶
func (om *OrderedMap) Move(key interface{}, last bool) (ok bool)
Move an existing key to either the end of the OrderedMap
func (*OrderedMap) MoveFirst ¶
func (om *OrderedMap) MoveFirst(key interface{}) (ok bool)
MoveFirst is a shortcut to Move a key to the beginning of the map
func (*OrderedMap) MoveLast ¶
func (om *OrderedMap) MoveLast(key interface{}) (ok bool)
MoveLast is a shortcut to Move a key to the end o the map
func (*OrderedMap) Pop ¶
func (om *OrderedMap) Pop(last bool) (key interface{}, value interface{}, ok bool)
Pop and return key:value for the newest or oldest element on the OrderedMap
func (*OrderedMap) PopFirst ¶
func (om *OrderedMap) PopFirst() (key interface{}, value interface{}, ok bool)
PopFirst is a shortcut to Pop the first element
func (*OrderedMap) PopLast ¶
func (om *OrderedMap) PopLast() (key interface{}, value interface{}, ok bool)
PopLast is a shortcut to Pop the last element
func (*OrderedMap) Set ¶
func (om *OrderedMap) Set(key interface{}, value interface{})
Set the key value, if the key overwrites an existing entry, the original insertion position is left unchanged, otherwise the key is inserted at the end.