ordmap

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

Package ordmap implements an ordered map type.

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
}

Map is like a Go map[K]V but is ordered: it retains the insertion/update ordering where less recently updated elements precede more recently updated elements.

func (*Map[K, V]) All added in v0.0.2

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

All returns an iterator over key-value pairs in the map. The iteration order follows the map ordering: least recently updated first.

func (*Map[K, V]) Delete

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

Delete deletes the value for a key.

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(key K) (val V, ok bool)

Get returns the value stored in the map for a key, or the zero value of V if no value is present. The ok result indicates whether the key was found in the map.

func (*Map[K, V]) Keys

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

Keys returns an iterator over keys in the map. The iteration order follows the map ordering: least recently updated first.

func (*Map[K, V]) Set

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

Set sets the value for a key.

func (*Map[K, V]) Values

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

Values returns an iterator over values in the map. The iteration order follows the map ordering: least recently updated first.

Jump to

Keyboard shortcuts

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