orderedutil

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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
}

Key to value mapping that remembers the order keys were first stored in; storing an existing key keeps its place, deleting it forgets the place, a nil *Map reads as empty and the zero Map is ready to use

func Merge

func Merge[K comparable, V any](maps ...*Map[K, V]) *Map[K, V]

New map of the inputs' pairs taken left to right, a later value for a key replacing the earlier one in its first place; nil inputs read as empty

func NewMap

func NewMap[K comparable, V any]() *Map[K, V]

Empty map

func (*Map[K, V]) All

func (m *Map[K, V]) All() iter.Seq2[K, V]

Key value pairs in insertion order; the loop body may change the map, pairs it deletes before they are reached are skipped and pairs it adds come last

func (*Map[K, V]) Clear

func (m *Map[K, V]) Clear()

Removes every key, the map keeping its identity for everyone holding it

func (*Map[K, V]) Clone

func (m *Map[K, V]) Clone() *Map[K, V]

New map holding the same pairs in the same order, empty for a nil map

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(k K) bool

Removes k in constant amortized time, true when it was present

func (*Map[K, V]) First

func (m *Map[K, V]) First() (K, V, bool)

Earliest stored key still present and its value, false when the map is empty

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(k K) (V, bool)

Value stored under k, false when k is absent

func (*Map[K, V]) Has

func (m *Map[K, V]) Has(k K) bool

Whether k is present

func (*Map[K, V]) Keys

func (m *Map[K, V]) Keys() []K

Every key in insertion order as a new slice the caller owns, nil when there are none

func (*Map[K, V]) Len

func (m *Map[K, V]) Len() int

Number of keys

func (*Map[K, V]) Set

func (m *Map[K, V]) Set(k K, v V)

Stores v under k, a new key going last and an existing key keeping its place

func (*Map[K, V]) Values

func (m *Map[K, V]) Values() []V

Every value in insertion order as a new slice the caller owns, nil only for a nil map

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL