Documentation
¶
Index ¶
- type Iterator
- type OrderedMap
- func (o *OrderedMap[K, V]) Back() *Iterator[K, V]
- func (o *OrderedMap[K, V]) Count() int
- func (o *OrderedMap[K, V]) Delete(key K)
- func (o *OrderedMap[K, V]) Front() *Iterator[K, V]
- func (o *OrderedMap[K, V]) Get(key K) (V, bool)
- func (o *OrderedMap[K, V]) Iterator() func() (*int, *K, V)
- func (o *OrderedMap[K, V]) Set(key K, val V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator[K comparable, V any] struct { Key *K Value V // contains filtered or unexported fields }
Iterator starting at OrderedMap.Front or OrderedMap.Back
type OrderedMap ¶
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedMap definition data is stored in insertion order
func NewOrderedMap ¶
func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V]
NewOrderedMap creates a new OrderedMap of type K
func (*OrderedMap[K, V]) Back ¶
func (o *OrderedMap[K, V]) Back() *Iterator[K, V]
Back returns an Iterator pointing to the newest (inserted-last) keyValue
func (*OrderedMap[K, V]) Count ¶
func (o *OrderedMap[K, V]) Count() int
Count returns the count of keys in OrderedMap
func (*OrderedMap[K, V]) Delete ¶
func (o *OrderedMap[K, V]) Delete(key K)
Delete will remove the key and its associated value.
func (*OrderedMap[K, V]) Front ¶
func (o *OrderedMap[K, V]) Front() *Iterator[K, V]
Front returns an iterator pointing to the oldest (inserted-first) keyValue
func (*OrderedMap[K, V]) Get ¶
func (o *OrderedMap[K, V]) Get(key K) (V, bool)
Get will return the value associated with the key. If the key doesn't exist, the second return value will be false.
func (*OrderedMap[K, V]) Iterator ¶
func (o *OrderedMap[K, V]) Iterator() func() (*int, *K, V)
Iterator is used to loop through the stored key-value pairs. The returned anonymous function returns the index, key and value.
func (*OrderedMap[K, V]) Set ¶
func (o *OrderedMap[K, V]) Set(key K, val V)
Set will store a key-value pair. If the key already exists, it will overwrite the existing key-value pair