Documentation ¶
Overview ¶
Package ordmap implements ordered map.
Index ¶
- type OrderedMap
- func (m *OrderedMap[K, V]) Delete(k K)
- func (m *OrderedMap[K, V]) Get(k K) (V, bool)
- func (m *OrderedMap[K, V]) Has(k K) bool
- func (m *OrderedMap[K, V]) Keys() []K
- func (m *OrderedMap[K, V]) MustGet(k K) V
- func (m *OrderedMap[K, V]) Range() *OrderedMapIterator[K, V]
- func (m *OrderedMap[K, V]) Set(k K, v V)
- type OrderedMapIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrderedMap ¶
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedMap ordered map.
func New ¶
func New[K comparable, V any]() *OrderedMap[K, V]
New creates empty ordered map instance.
func (*OrderedMap[K, V]) Delete ¶
func (m *OrderedMap[K, V]) Delete(k K)
Delete deletes an element if it exists. Do nothing otherwise.
func (*OrderedMap[K, V]) Get ¶
func (m *OrderedMap[K, V]) Get(k K) (V, bool)
Get returns the value of the given key k.
func (*OrderedMap[K, V]) Has ¶ added in v0.0.2
func (m *OrderedMap[K, V]) Has(k K) bool
Has check if there is a value with the given key.
func (*OrderedMap[K, V]) Keys ¶
func (m *OrderedMap[K, V]) Keys() []K
Keys return all keys of data collected in the proper order.
func (*OrderedMap[K, V]) MustGet ¶
func (m *OrderedMap[K, V]) MustGet(k K) V
MustGet works the same as Get except it panics if there's no given key in the data collected.
func (*OrderedMap[K, V]) Range ¶
func (m *OrderedMap[K, V]) Range() *OrderedMapIterator[K, V]
Range return an iterator over collected data.
func (*OrderedMap[K, V]) Set ¶
func (m *OrderedMap[K, V]) Set(k K, v V)
Set sets value v for key k. The order depends on whether value k was taken before. Once it was order does not change, only value does. Otherwise, the key k supposed to be the last after the insertion.
type OrderedMapIterator ¶
type OrderedMapIterator[K comparable, V any] struct { // contains filtered or unexported fields }
OrderedMapIterator iterator over ordered map.
func (*OrderedMapIterator[K, V]) KV ¶
func (it *OrderedMapIterator[K, V]) KV() (K, V)
KV returns (key, value) pair of current iteration.
func (*OrderedMapIterator[K, V]) Next ¶
func (it *OrderedMapIterator[K, V]) Next() bool
Next checks if not all elements has been iterated yet.