Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry[K cmp.Ordered, V any] struct { // Key is the key of the entry. Key K // Value is the value of the entry. Value V }
Entry is a key-value pair in an OrderedMap.
type ErrKeyNotFound ¶
ErrKeyNotFound is an error that is returned when a key is not found in the map.
func NewErrKeyNotFound ¶
func NewErrKeyNotFound[K cmp.Ordered](key K) *ErrKeyNotFound[K]
NewErrKeyNotFound creates a new ErrKeyNotFound error.
Parameters:
- key: The key that was not found.
Returns:
- *ErrKeyNotFound: A pointer to the newly created ErrKeyNotFound. Never returns nil.
func (*ErrKeyNotFound[K]) Error ¶
func (e *ErrKeyNotFound[K]) Error() string
Error implements the error interface.
Message: "key ("{{ .Key }}") not found"
type OMIterator ¶
OMIterator is an iterator for an OrderedMap.
func NewOMIterator ¶
func NewOMIterator[K cmp.Ordered, V any](m *OrderedMap[K, V]) *OMIterator[K, V]
NewOMIterator creates a new OMIterator.
Parameters:
- m: The map to iterate over.
Returns:
- *OMIterator: A pointer to the newly created OMIterator. Nil if m is nil.
func (*OMIterator[K, V]) Consume ¶
func (i *OMIterator[K, V]) Consume() (*Entry[K, V], error)
Consume implements the common.Iterater interface.
func (*OMIterator[K, V]) Restart ¶
func (i *OMIterator[K, V]) Restart()
Restart implements the common.Iterater interface.
type OrderedMap ¶
OrderedMap is a map that is ordered by the keys.
func NewOrderedMap ¶
func NewOrderedMap[K cmp.Ordered, V any]() *OrderedMap[K, V]
NewOrderedMap creates a new OrderedMap.
Returns:
- *OrderedMap: A pointer to the newly created OrderedMap. Never returns nil.
func (*OrderedMap[K, V]) Add ¶
func (m *OrderedMap[K, V]) Add(key K, value V, force bool) bool
Add adds a key-value pair to the map.
Parameters:
- key: The key to add.
- value: The value to add.
- force: If true, the value will be added even if the key already exists. If false, the value will not be added if the key already exists.
Returns:
- bool: True if the value was added to the map, false otherwise.
func (*OrderedMap[K, V]) Iterator ¶
func (m *OrderedMap[K, V]) Iterator() luc.Iterater[*Entry[K, V]]
Iterator implements the common.Iterable interface.
Never returns nil.
func (*OrderedMap[K, V]) KeyIterator ¶
func (m *OrderedMap[K, V]) KeyIterator() luc.Iterater[K]
KeyIterator is a method that returns an iterator over the keys in the map.
Returns:
- common.Iterater[K]: An iterator over the keys in the map. Never returns nil.
func (*OrderedMap[K, V]) Map ¶ added in v0.1.6
func (m *OrderedMap[K, V]) Map() map[K]V
Map is a method that returns the map of the values in the map.
Returns:
- map[K]V: The map of the values in the map. Never returns nil.
func (*OrderedMap[K, V]) Size ¶
func (m *OrderedMap[K, V]) Size() int
Size is a method that returns the number of keys in the map.
Returns:
- int: The number of keys in the map.