Documentation
¶
Index ¶
- type OrderedMap
- func (om *OrderedMap[K, V]) Clear()
- func (om *OrderedMap[K, V]) Delete(k K) bool
- func (om *OrderedMap[K, V]) Get(k K) (V, bool)
- func (om *OrderedMap[K, V]) Has(k K) bool
- func (om *OrderedMap[K, V]) IsZero() bool
- func (om *OrderedMap[K, V]) Keys() []K
- func (om *OrderedMap[K, V]) Len() int
- func (om *OrderedMap[K, V]) MarshalJSON() ([]byte, error)
- func (om *OrderedMap[K, V]) Range(f func(k K, v V) bool)
- func (om *OrderedMap[K, V]) Set(k K, v V)
- func (om *OrderedMap[K, V]) ToMap() map[K]V
- func (om *OrderedMap[K, V]) UnmarshalJSON(data []byte) error
- func (om *OrderedMap[K, V]) Values() []V
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 keeps insertion order for iteration and JSON marshalling. Existing keys updated via Set keep their original position.
func (*OrderedMap[K, V]) Delete ¶
func (om *OrderedMap[K, V]) Delete(k K) bool
Delete removes k if present. Returns true if removed.
func (*OrderedMap[K, V]) Get ¶
func (om *OrderedMap[K, V]) Get(k K) (V, bool)
Get returns the value for k.
func (*OrderedMap[K, V]) Has ¶
func (om *OrderedMap[K, V]) Has(k K) bool
Has reports whether k exists.
func (*OrderedMap[K, V]) IsZero ¶ added in v1.1.0
func (om *OrderedMap[K, V]) IsZero() bool
IsZero reports whether the map contains no entries. This enables encoding/json to respect omitempty and omitzero struct tags.
func (*OrderedMap[K, V]) Keys ¶
func (om *OrderedMap[K, V]) Keys() []K
Keys returns keys in insertion order.
func (*OrderedMap[K, V]) Len ¶
func (om *OrderedMap[K, V]) Len() int
Len returns the number of items.
func (*OrderedMap[K, V]) MarshalJSON ¶
func (om *OrderedMap[K, V]) MarshalJSON() ([]byte, error)
func (*OrderedMap[K, V]) Range ¶
func (om *OrderedMap[K, V]) Range(f func(k K, v V) bool)
Range iterates in insertion order; stop when f returns false.
func (*OrderedMap[K, V]) Set ¶
func (om *OrderedMap[K, V]) Set(k K, v V)
Set inserts k with value v preserving insertion order. If k exists, only its value is updated.
func (*OrderedMap[K, V]) ToMap ¶
func (om *OrderedMap[K, V]) ToMap() map[K]V
ToMap copies to a regular map (order lost).
func (*OrderedMap[K, V]) UnmarshalJSON ¶
func (om *OrderedMap[K, V]) UnmarshalJSON(data []byte) error
func (*OrderedMap[K, V]) Values ¶
func (om *OrderedMap[K, V]) Values() []V
Values returns values in insertion order.