linkedmap

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LinkedMap

type LinkedMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

LinkedMap is a map that preserves insertion order of keys.

func New

func New[K comparable, V any]() *LinkedMap[K, V]

New returns an empty LinkedMap

func (*LinkedMap[K, V]) Entries

func (m *LinkedMap[K, V]) Entries() []struct {
	Key   K
	Value V
}

Entries returns slice of key/value pairs in insertion order

func (*LinkedMap[K, V]) Get

func (m *LinkedMap[K, V]) Get(key K) (V, bool)

Get returns a value and a boolean if found

func (*LinkedMap[K, V]) Keys

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

Keys returns keys in insertion order. A copy of the keys slice is returned to prevent external modification.

func (*LinkedMap[K, V]) Len

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

Len returns number of entries

func (*LinkedMap[K, V]) Range

func (m *LinkedMap[K, V]) Range(fn func(K, V))

Range iterates over entries in insertion order

func (*LinkedMap[K, V]) Set

func (m *LinkedMap[K, V]) Set(key K, value V)

Set adds or updates a key/value pair. If the key is new, it preserves insertion order.

func (*LinkedMap[K, V]) Values

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

Values returns values in insertion order

Jump to

Keyboard shortcuts

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