Documentation
¶
Index ¶
- type Iterator
- type OMIterator
- type OMap
- func (m *OMap[T]) Delete(key any) (T, bool)
- func (m *OMap[T]) Exists(key any) bool
- func (m *OMap[T]) Get(key any) (T, bool)
- func (m *OMap[T]) IndexOf(key any) int
- func (m *OMap[T]) Iterator() Iterator[T]
- func (m *OMap[T]) Keys() []any
- func (m *OMap[T]) Len() int
- func (m *OMap[T]) ReplaceKey(oldKey any, newKey any) bool
- func (m *OMap[T]) Set(key any, val T)
- func (m *OMap[T]) SetAfter(presentKey any, newKey any, value T) (int, bool)
- func (m *OMap[T]) SetBefore(presentKey any, newKey any, value T) (int, bool)
- func (m *OMap[T]) Values() []T
- type OrderedMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator[T any] interface { HasNext() bool Next() bool GetNext() (T, bool) GetCurrent() (T, bool) GetCurrentV() (T, int, bool) }
Iterator is an iterator over a OrderedMap.
func NewIterator ¶ added in v0.2.2
type OMIterator ¶ added in v0.2.0
type OMIterator[T any] struct { // contains filtered or unexported fields }
OMIterator is an Iterator implementation.
func (*OMIterator[T]) GetCurrent ¶ added in v0.2.0
func (i *OMIterator[T]) GetCurrent() (T, bool)
GetCurrent returns the current element and true if there was a current element in the OMIterator.
func (*OMIterator[T]) GetCurrentV ¶ added in v0.2.1
func (i *OMIterator[T]) GetCurrentV() (T, int, bool)
GetCurrentV returns the current element, the index and true if there was a current element in the OMIterator.
func (*OMIterator[T]) GetNext ¶ added in v0.2.0
func (i *OMIterator[T]) GetNext() (T, bool)
GetNext returns the next element in the OMIterator.
func (*OMIterator[T]) HasNext ¶ added in v0.2.0
func (i *OMIterator[T]) HasNext() bool
HasNext returns true if the OMIterator has a next element.
func (*OMIterator[T]) Next ¶ added in v0.2.0
func (i *OMIterator[T]) Next() bool
Next moves the OMIterator to the next element and returns true if there was a next element in the OMIterator.
type OMap ¶ added in v0.2.1
type OMap[T any] struct { // contains filtered or unexported fields }
OMap is the OrderedMap implementation.
func (*OMap[T]) Delete ¶ added in v0.2.1
Delete deletes the value for the given key. Returns deleted value, true if the key is found.
func (*OMap[T]) Get ¶ added in v0.2.1
Get returns the value for the given key. If the key does not exist, the second argument will be false.
func (*OMap[T]) IndexOf ¶ added in v0.2.4
IndexOf returns the index of the given key. If the key does not exist, returns -1.
func (*OMap[T]) ReplaceKey ¶ added in v0.2.1
ReplaceKey replaces the key of the given key with the new key. Returns false if the key does not exist.
func (*OMap[T]) SetAfter ¶ added in v0.2.1
SetAfter sets the new (newKey, value) pair after the given presentKey. Return false if presentKey does not exist or if newKey already exists.
type OrderedMap ¶
type OrderedMap[T any] interface { Len() int Set(key any, val T) Get(key any) (T, bool) Delete(key any) (T, bool) Keys() []any Values() []T Exists(key any) bool IndexOf(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() Iterator[T] }
OrderedMap is a map with ordered keys.