orderedmap

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry[K comparable, V any] struct {
	Key   K
	Value V
}

type Map

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

Map is a generic data structure that maintains the order of keys.

func New

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

New creates a new Map.

func (*Map[K, V]) Delete

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

Delete removes a key-value pair from the Map.

func (*Map[K, V]) Each

func (om *Map[K, V]) Each(cb func(key K, value V))

func (*Map[K, V]) Entries

func (om *Map[K, V]) Entries() []Entry[K, V]

Entries returns the key-value pairs in the order they were added.

func (*Map[K, V]) Get

func (om *Map[K, V]) Get(key K) (V, bool)

Get retrieves a value by key.

func (*Map[K, V]) Keys

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

Keys returns the keys in the order they were added.

func (*Map[K, V]) Set

func (om *Map[K, V]) Set(key K, value V)

Set adds or updates a key-value pair in the Map.

func (*Map[K, V]) Values

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

Values returns the values in the order of their keys.

Jump to

Keyboard shortcuts

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