Documentation ¶
Index ¶
- func JsonToMap(j Json) map[string]any
- type El
- type Element
- type Json
- type OrderedMap
- func (m *OrderedMap[K, V]) Back() *Element[K, V]
- func (m *OrderedMap[K, V]) Copy() *OrderedMap[K, V]
- func (m *OrderedMap[K, V]) Delete(key K) (didDelete bool)
- func (m *OrderedMap[K, V]) ForEach(f func(k K, v V))
- func (m *OrderedMap[K, V]) ForEachIndexed(f func(i int, k K, v V))
- func (m *OrderedMap[K, V]) ForEachIndexedE(f func(i int, k K, v V) error) error
- func (m *OrderedMap[K, V]) Front() *Element[K, V]
- func (m *OrderedMap[K, V]) Get(key K) (value V, ok bool)
- func (m *OrderedMap[K, V]) GetElement(key K) *Element[K, V]
- func (m *OrderedMap[K, V]) GetN(key K) V
- func (m *OrderedMap[K, V]) GetOrCreate(key K, value V) V
- func (m *OrderedMap[K, V]) GetOrCreateFunc(key K, f func() V) V
- func (m *OrderedMap[K, V]) GetOrDefault(key K, defaultValue V) V
- func (m *OrderedMap[K, V]) GetPathS(path K) string
- func (m *OrderedMap[K, V]) GetS(key K) string
- func (m *OrderedMap[K, V]) Keys() (keys []K)
- func (m *OrderedMap[K, V]) Len() int
- func (m *OrderedMap[K, V]) Rename(key K, newkey K)
- func (m *OrderedMap[K, V]) Set(key K, value V) bool
- func (m *OrderedMap[K, V]) SetAll(s *OrderedMap[K, V])
- func (m *OrderedMap[K, V]) SetAllMap(s map[K]V)
- func (m *OrderedMap[K, V]) SetIfAbsent(key K, value V) bool
- func (m *OrderedMap[K, V]) SetIfAbsentFunc(key K, f func() V) bool
- func (m *OrderedMap[K, V]) String() string
- func (m *OrderedMap[K, V]) ToArray() []El[K, V]
- func (m *OrderedMap[K, V]) ToMap() map[K]V
- type Set
- func (s Set[K]) Clear()
- func (s Set[K]) Clone() Set[K]
- func (s Set[K]) Contains(key K) bool
- func (s Set[K]) Equals(other Set[K]) bool
- func (s Set[K]) Hash() string
- func (s Set[K]) Put(key K)
- func (s Set[K]) PutAll(keys []K)
- func (s Set[K]) PutAllKeys(m map[K]any)
- func (s Set[K]) PutAllOrderedKeys(m *OrderedMap[K, any])
- func (s Set[K]) PutSet(keys Set[K])
- func (s Set[K]) Remove(key K)
- func (s Set[K]) Size() int
- func (s Set[K]) ToSlice() []K
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Element ¶
type Element[K comparable, V any] struct { // The key that corresponds to this element in the ordered map. Key K // The value stored with this element. Value V // contains filtered or unexported fields }
Element is an element of a null terminated (non circular) intrusive doubly linked list that contains the key of the correspondent element in the ordered map too.
type OrderedMap ¶
func NewOrderedMap ¶
func NewOrderedMap[K cmp.Ordered, V any]() *OrderedMap[K, V]
func (*OrderedMap[K, V]) Back ¶
func (m *OrderedMap[K, V]) Back() *Element[K, V]
Back will return the element that is the last (most recent Set element). If there are no elements this will return nil.
func (*OrderedMap[K, V]) Copy ¶
func (m *OrderedMap[K, V]) Copy() *OrderedMap[K, V]
Copy returns a new OrderedMap with the same elements. Using Copy while there are concurrent writes may mangle the result.
func (*OrderedMap[K, V]) Delete ¶
func (m *OrderedMap[K, V]) Delete(key K) (didDelete bool)
Delete will remove a key from the map. It will return true if the key was removed (the key did exist).
func (*OrderedMap[K, V]) ForEach ¶
func (m *OrderedMap[K, V]) ForEach(f func(k K, v V))
func (*OrderedMap[K, V]) ForEachIndexed ¶
func (m *OrderedMap[K, V]) ForEachIndexed(f func(i int, k K, v V))
func (*OrderedMap[K, V]) ForEachIndexedE ¶
func (m *OrderedMap[K, V]) ForEachIndexedE(f func(i int, k K, v V) error) error
func (*OrderedMap[K, V]) Front ¶
func (m *OrderedMap[K, V]) Front() *Element[K, V]
Front will return the element that is the first (oldest Set element). If there are no elements this will return nil.
func (*OrderedMap[K, V]) Get ¶
func (m *OrderedMap[K, V]) Get(key K) (value V, ok bool)
Get returns the value for a key. If the key does not exist, the second return parameter will be false and the value will be nil.
func (*OrderedMap[K, V]) GetElement ¶
func (m *OrderedMap[K, V]) GetElement(key K) *Element[K, V]
GetElement returns the element for a key. If the key does not exist, the pointer will be nil.
func (*OrderedMap[K, V]) GetN ¶
func (m *OrderedMap[K, V]) GetN(key K) V
GetN returns the value for a key. If the key does not exist, it returns the zero value for type V, such as 0 for int or an empty string for string.
func (*OrderedMap[K, V]) GetOrCreate ¶
func (m *OrderedMap[K, V]) GetOrCreate(key K, value V) V
func (*OrderedMap[K, V]) GetOrCreateFunc ¶
func (m *OrderedMap[K, V]) GetOrCreateFunc(key K, f func() V) V
func (*OrderedMap[K, V]) GetOrDefault ¶
func (m *OrderedMap[K, V]) GetOrDefault(key K, defaultValue V) V
GetOrDefault returns the value for a key. If the key does not exist, returns the default value instead.
func (*OrderedMap[K, V]) GetPathS ¶
func (m *OrderedMap[K, V]) GetPathS(path K) string
GetPathS returns the value at the specified path in the OrderedMap if that value is of string type The path is a dot-separated string representing a nested structure of keys. If the path does not exist or any intermediate key is not of type *OrderedMap[K, V], an empty string is returned.
func (*OrderedMap[K, V]) GetS ¶
func (m *OrderedMap[K, V]) GetS(key K) string
GetS returns the value for a key if it exists and has string type. Otherwise, it returns an empty string.
func (*OrderedMap[K, V]) Keys ¶
func (m *OrderedMap[K, V]) Keys() (keys []K)
Keys returns all of the keys in the order they were inserted. If a key was replaced it will retain the same position. To ensure most recently set keys are always at the end you must always Delete before Set.
func (*OrderedMap[K, V]) Len ¶
func (m *OrderedMap[K, V]) Len() int
Len returns the number of elements in the map.
func (*OrderedMap[K, V]) Rename ¶
func (m *OrderedMap[K, V]) Rename(key K, newkey K)
func (*OrderedMap[K, V]) Set ¶
func (m *OrderedMap[K, V]) Set(key K, value V) bool
Set will set (or replace) a value for a key. If the key was new, then true will be returned. The returned value will be false if the value was replaced (even if the value was the same).
func (*OrderedMap[K, V]) SetAll ¶
func (m *OrderedMap[K, V]) SetAll(s *OrderedMap[K, V])
func (*OrderedMap[K, V]) SetAllMap ¶
func (m *OrderedMap[K, V]) SetAllMap(s map[K]V)
func (*OrderedMap[K, V]) SetIfAbsent ¶
func (m *OrderedMap[K, V]) SetIfAbsent(key K, value V) bool
SetIfAbsent sets a value for a key only if the key does not already exist in the map. It returns true if the value was set successfully, or false if the key already exists.
func (*OrderedMap[K, V]) SetIfAbsentFunc ¶
func (m *OrderedMap[K, V]) SetIfAbsentFunc(key K, f func() V) bool
SetIfAbsentFunc sets a value for a key only if the key does not already exist in the map. It returns true if the value was set successfully, or false if the key already exists.
func (*OrderedMap[K, V]) String ¶
func (m *OrderedMap[K, V]) String() string
func (*OrderedMap[K, V]) ToArray ¶
func (m *OrderedMap[K, V]) ToArray() []El[K, V]
func (*OrderedMap[K, V]) ToMap ¶
func (m *OrderedMap[K, V]) ToMap() map[K]V
type Set ¶
func (Set[K]) PutAllKeys ¶
func (Set[K]) PutAllOrderedKeys ¶
func (s Set[K]) PutAllOrderedKeys(m *OrderedMap[K, any])