Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator[T any] interface { // HasNext returns true if the omIter has a next element. HasNext() bool // Next moves the omIter to the next element and returns true if there was a next element in the omIter. Next() bool // GetNext returns the next element in the omIter. GetNext() (T, bool) // GetCurrent returns the current element and true if there was a current element in the omIter. GetCurrent() (T, bool) // GetCurrentV returns the current element, the index and true if there was a current element in the omIter. GetCurrentV() (T, int, bool) }
Iterator is an iterator over a OrderedMap.
func NewIterator ¶ added in v0.2.2
NewIterator returns a new Iterator.
type OrderedMap ¶
type OrderedMap[T any] interface { // Len returns the number of elements in the map. Len() int // Set sets the value for the given key. Set(key any, val T) // Get returns the value for the given key. // If the key does not exist, the second argument will be false. Get(key any) (T, bool) // Delete deletes the value for the given key. // Returns deleted value, true if the key is found. Delete(key any) (T, bool) // Keys returns the keys of the map. Keys() []any // Values returns the values of the map. Values() []T // Exists returns true if the key exists in the map. Exists(key any) bool // IndexOf returns the index of the given key. // If the key does not exist, returns -1. IndexOf(key any) int // ReplaceKey replaces the key of the given key with the new key. // Returns false if the key does not exist. ReplaceKey(oldKey any, newKey any) bool // SetBefore sets the new (newKey, value) pair before the given presentKey. // Return false if presentKey does not exist or if newKey already exists. SetBefore(presentKey any, newKey any, val T) (int, bool) // SetAfter sets the new (newKey, value) pair after the given presentKey. // Return false if presentKey does not exist or if newKey already exists. SetAfter(presentKey any, newKey any, val T) (int, bool) // Iterator returns an omIter for the map. Iterator() Iterator[T] }
OrderedMap is a map with ordered keys.
Click to show internal directories.
Click to hide internal directories.