orderedmap

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package orderedmap provides an ordered map where keys are sorted by insertion order.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderedMap

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

OrderedMap is a map datastructure, but the keys are ordered by insertion order, making it easier when order is important

func New

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

New creates a new OrderedMap

func (*OrderedMap[K, V]) Delete

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

Delete deletes K from map

func (*OrderedMap[K, V]) Get

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

Get retruns value for key

func (*OrderedMap[K, V]) Keys

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

Keys returns the keys for the map. ordered by insert

func (*OrderedMap[K, V]) Range

func (om *OrderedMap[K, V]) Range() iter.Seq2[K, V]

Range returns iter.Seq2 for iterating over values in insertion order

func (*OrderedMap[K, V]) Set

func (om *OrderedMap[K, V]) Set(key K, v V)

Set sets V for K. if the key has been set before, the order does not get changed

func (*OrderedMap[K, V]) Values

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

Values returns a list of values, ordered by insert

Jump to

Keyboard shortcuts

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