Documentation ¶
Overview ¶
Package sequencedmap provides a map implementation that maintains the order of keys as they are added.
Index ¶
- type Element
- type Map
- func (m *Map[K, V]) All() iter.Seq2[K, V]
- func (m *Map[K, V]) AllUntyped() iter.Seq2[any, any]
- func (m *Map[K, V]) Delete(key K)
- func (m *Map[K, V]) Get(key K) (V, bool)
- func (m *Map[K, V]) GetKeyType() reflect.Type
- func (m *Map[K, V]) GetOrZero(key K) V
- func (m *Map[K, V]) GetUntyped(key any) (any, bool)
- func (m *Map[K, V]) GetValueType() reflect.Type
- func (m *Map[K, V]) Has(key K) bool
- func (m *Map[K, V]) Init()
- func (m *Map[K, V]) Keys() iter.Seq[K]
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) MarshalJSON() ([]byte, error)
- func (m *Map[K, V]) NavigateWithKey(key string) (any, error)
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) SetUntyped(key, value any) error
- func (m *Map[K, V]) SyncChangesWithSyncFunc(ctx context.Context, model any, valueNode *yaml.Node, ...) (*yaml.Node, error)
- func (m *Map[K, V]) Values() iter.Seq[V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element[K comparable, V any] struct { Key K Value V }
Element is a key-value pair that is stored in a sequenced map.
func NewElem ¶
func NewElem[K comparable, V any](key K, value V) *Element[K, V]
NewElem creates a new element with the specified key and value.
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a map implementation that maintains the order of keys as they are added.
func New ¶
func New[K comparable, V any](elements ...*Element[K, V]) *Map[K, V]
New creates a new map with the specified elements.
func NewWithCapacity ¶
func NewWithCapacity[K comparable, V any](capacity int, elements ...*Element[K, V]) *Map[K, V]
NewWithCapacity creates a new map with the specified capacity and elements.
func (*Map[K, V]) All ¶
All returns an iterator that iterates over all elements in the map, in the order they were added.
func (*Map[K, V]) AllUntyped ¶
AllUntyped returns an iterator that iterates over all elements in the map with untyped key and value. This allows for using the map in generic code.
func (*Map[K, V]) Delete ¶
func (m *Map[K, V]) Delete(key K)
Delete removes the element with the specified key from the map.
func (*Map[K, V]) Get ¶
Get returns the value for the specified key and a boolean indicating whether the key was found.
func (*Map[K, V]) GetKeyType ¶
GetKeyType returns the type of the keys in the map.
func (*Map[K, V]) GetOrZero ¶
func (m *Map[K, V]) GetOrZero(key K) V
GetOrZero returns the value for the specified key or the zero value if the key is not found.
func (*Map[K, V]) GetUntyped ¶
GetUntyped returns the untyped value for the specified key with untyped key and a boolean indicating whether the key was found. This allows for using the map in generic code. If they key is not of the correct type, the zero value is returned.
func (*Map[K, V]) GetValueType ¶
GetValueType returns the type of the values in the map.
func (*Map[K, V]) Has ¶
Has returns a boolean indicating whether the map contains the specified key.
func (*Map[K, V]) Init ¶
func (m *Map[K, V]) Init()
Init initializes the underlying resources of the map.
func (*Map[K, V]) Keys ¶
Keys returns an iterator that iterates over all keys in the map, in the order they were added.
func (*Map[K, V]) MarshalJSON ¶
MarshalJSON returns the JSON representation of the map.
func (*Map[K, V]) NavigateWithKey ¶
NavigateWithKey returns the value for the specified key with the key as a string. This is an implementation of the jsonpointer.KeyNavigable interface.
func (*Map[K, V]) Set ¶
func (m *Map[K, V]) Set(key K, value V)
Set sets the value for the specified key.
func (*Map[K, V]) SetUntyped ¶
SetUntyped sets the value for the specified key with untyped key and value. This allows for using the map in generic code. An error is returned if the key or value is not of the correct type.