Documentation
¶
Index ¶
- type IIterator
- type IOrderedMap
- type Iterator
- type OrderedMap
- func (m *OrderedMap[T]) Delete(key any) (T, bool)
- func (m *OrderedMap[T]) Get(key any) (T, bool)
- func (m *OrderedMap[T]) Index(key any) int
- func (m *OrderedMap[T]) Iterator() IIterator[T]
- func (m *OrderedMap[T]) Len() int
- func (m *OrderedMap[T]) ReplaceKey(oldKey any, newKey any) bool
- func (m *OrderedMap[T]) Set(key any, val T)
- func (m *OrderedMap[T]) SetAfter(presentKey any, newKey any, value T) (int, bool)
- func (m *OrderedMap[T]) SetBefore(presentKey any, newKey any, value T) (int, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IIterator ¶ added in v0.3.0
type IIterator[T any] interface { HasNext() bool Next() bool GetNext() (T, bool) GetCurrent() T GetCurrentV() (T, int, bool) }
IIterator is an iterator over a IOrderedMap.
type IOrderedMap ¶ added in v0.3.0
type IOrderedMap[T any] interface { Len() int Set(key any, val T) Get(key any) (T, bool) Delete(key any) (T, bool) Index(key any) int ReplaceKey(oldKey any, newKey any) bool SetBefore(presentKey any, newKey any, val T) (int, bool) SetAfter(presentKey any, newKey any, val T) (int, bool) Iterator() IIterator[T] }
IOrderedMap is a map with ordered keys.
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator is an IIterator implementation.
func (*Iterator[T]) GetCurrent ¶
func (i *Iterator[T]) GetCurrent() T
GetCurrent returns the current element in the Iterator. Prefer use with HasNext() or with Next() to avoid false positives. Alternatively, use GetCurrentV(), which is more verbose.
func (*Iterator[T]) GetCurrentV ¶ added in v0.2.1
GetCurrentV returns the current element, the index and true if there was a current element in the Iterator.
type OrderedMap ¶
type OrderedMap[T any] struct { // contains filtered or unexported fields }
OrderedMap is the IOrderedMap implementation.
func (*OrderedMap[T]) Delete ¶
func (m *OrderedMap[T]) Delete(key any) (T, bool)
Delete deletes the value for the given key. Returns deleted value, true if the key is found.
func (*OrderedMap[T]) Get ¶
func (m *OrderedMap[T]) Get(key any) (T, bool)
Get returns the value for the given key. If the key does not exist, the second argument will be false.
func (*OrderedMap[T]) Index ¶
func (m *OrderedMap[T]) Index(key any) int
Index returns the index of the given key. If the key does not exist, returns -1.
func (*OrderedMap[T]) Iterator ¶ added in v0.2.0
func (m *OrderedMap[T]) Iterator() IIterator[T]
IIterator returns an Iterator for the map.
func (*OrderedMap[T]) Len ¶
func (m *OrderedMap[T]) Len() int
Len returns the number of elements in the map.
func (*OrderedMap[T]) ReplaceKey ¶
func (m *OrderedMap[T]) ReplaceKey(oldKey any, newKey any) bool
ReplaceKey replaces the key of the given key with the new key. Returns false if the key does not exist.
func (*OrderedMap[T]) Set ¶
func (m *OrderedMap[T]) Set(key any, val T)
Set sets the value for the given key.