Documentation ¶
Index ¶
- func Iterate[K comparable, V any](ctx context.Context, m *Map[K, V]) <-chan Pair[K, V]
- func Len[K comparable, V any](m *Map[K, V]) int
- type Map
- func (o *Map[K, V]) FindValueUntyped(key string) any
- func (o *Map[K, V]) First() Pair[K, V]
- func (o *Map[K, V]) GetKeyType() reflect.Type
- func (o *Map[K, V]) GetOrZero(k K) V
- func (o *Map[K, V]) GetValueType() reflect.Type
- func (o *Map[K, V]) IsZero() bool
- func (o *Map[K, V]) ToYamlNode(n NodeBuilder, l any) *yaml.Node
- type MapToYamlNoder
- type NodeBuilder
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Map ¶
type Map[K comparable, V any] struct { *wk8orderedmap.OrderedMap[K, V] }
Map represents an ordered map where the key must be a comparable type, the ordering is based on insertion order.
func FromPairs ¶
func FromPairs[K comparable, V any](pairs ...Pair[K, V]) *Map[K, V]
FromPairs creates an `OrderedMap` from an array of pairs. Use `NewPair()` to generate input parameters.
func SortAlpha ¶
func SortAlpha[K comparable, V any](m *Map[K, V]) *Map[K, V]
SortAlpha sorts the map by keys in alphabetical order.
func ToOrderedMap ¶
func ToOrderedMap[K comparable, V any](m map[K]V) *Map[K, V]
ToOrderedMap converts a `map` to `OrderedMap`.
func (*Map[K, V]) FindValueUntyped ¶
FindValueUntyped finds a value in the ordered map by key if the stored value for that key implements GetValueUntyped otherwise just returns the value.
func (*Map[K, V]) GetKeyType ¶
GetKeyType returns the reflection type of the key.
func (*Map[K, V]) GetOrZero ¶
func (o *Map[K, V]) GetOrZero(k K) V
GetOrZero will return the value for the key if it exists, otherwise it will return the zero value for the value type.
func (*Map[K, V]) GetValueType ¶
GetValueType returns the reflection type of the value.
func (*Map[K, V]) ToYamlNode ¶
func (o *Map[K, V]) ToYamlNode(n NodeBuilder, l any) *yaml.Node
ToYamlNode converts the ordered map to a yaml node ready for marshalling.
type MapToYamlNoder ¶
type MapToYamlNoder interface {
ToYamlNode(n NodeBuilder, l any) *yaml.Node
}
type NodeBuilder ¶
type Pair ¶
type Pair[K comparable, V any] interface { Key() K KeyPtr() *K Value() V ValuePtr() *V Next() Pair[K, V] }
Pair represents a key/value pair in an ordered map returned for iteration.
func First ¶
func First[K comparable, V any](m *Map[K, V]) Pair[K, V]
First returns map's first pair for iteration. Safely handles nil pointer.
func NewPair ¶
func NewPair[K comparable, V any](key K, value V) Pair[K, V]
NewPair instantiates a `Pair` object for use with `FromPairs()`.