ordmap

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 0 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]) 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() []K

Keys returns a slice of all keys in the map in map order.

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(f func(key K, val V) bool)

Range calls f sequentially for each key and value present in the map following the map ordering: least recently updated first. If f returns false, Range stops the iteration.

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() []V

Values returns a slice of all values in the map in map order.

Jump to

Keyboard shortcuts

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