Documentation ¶
Overview ¶
Package orderedmap implements a generic ordered map that supports iteration in insertion order.
Index ¶
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 { // Pairs is the list of pairs in insertion order. It should _never_ be modified directly (use // Store instead), but can be used for read-only purposes (e.g., iterations). It is // specifically exported to allow serialization via gob encoding. Pairs []*Pair[K, V] // contains filtered or unexported fields }
OrderedMap is an ordered map that supports iteration in insertion order. It is an _internal_ helper struct for NilAway and lacks some of the features of a full map.
func (*OrderedMap[K, V]) Load ¶
func (m *OrderedMap[K, V]) Load(key K) (V, bool)
Load returns the value stored in the map for the key, with an additional bool indicating if the key was found.
func (*OrderedMap[K, V]) Store ¶
func (m *OrderedMap[K, V]) Store(key K, value V)
Store stores the value in the map for the key, overwriting the previous value if the key exists.
func (*OrderedMap[K, V]) Value ¶
func (m *OrderedMap[K, V]) Value(key K) V
Value returns the value stored in the map for the key, or the zero value if the key is not found. It is the same as Load, but without the additional bool.
type Pair ¶
type Pair[K comparable, V any] struct { Key K Value V }
Pair is a key-value pair stored in the ordered map.