Documentation
¶
Overview ¶
Package ordered provides an insertion-ordered map with live iteration. Wire-visible participant order, candidate ordering, round-robin state and deletion during iteration depend on those semantics.
Index ¶
- type Map
- func (m *Map[K, V]) All() iter.Seq2[K, V]
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Delete(key K) bool
- func (m *Map[K, V]) Get(key K) (V, bool)
- func (m *Map[K, V]) Has(key K) bool
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) MoveToBack(key K, value V)
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map keeps keys in first-insertion order. Set on an existing key keeps its position; MoveToBack removes and reinserts it at the end. Iteration is live: an entry deleted before it is visited is skipped and an entry appended during iteration is visited. The zero value is ready to use.
func (*Map[K, V]) All ¶
All iterates live entries in order with JavaScript Map semantics. Mutating the map inside the loop is allowed.
func (*Map[K, V]) Clear ¶
func (m *Map[K, V]) Clear()
Clear removes every entry. Dropping the index before compacting is safe because every entry is now a tombstone, so compact writes no index entry.
func (*Map[K, V]) Keys ¶
func (m *Map[K, V]) Keys() []K
Keys returns a snapshot of the live keys in order.
func (*Map[K, V]) MoveToBack ¶
func (m *Map[K, V]) MoveToBack(key K, value V)
MoveToBack re-inserts key at the end, as JavaScript `map.delete(k); map.set(k, v)` does. It is a plain Set when the key is absent.