omap

package
v0.0.0-...-77cd799 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package omap implements a very simple ordered map with just the absolute minimum features for our purpose. It's not very performant of whatever, but it's nice to use and easy to maintain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderedMap

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

OrderedMap implements a map ordered by the keys.

func New

func New[K cmp.Ordered, V any](size int) *OrderedMap[K, V]

New returns a new ordered map with space for size elements.

func (*OrderedMap[K, V]) Add

func (om *OrderedMap[K, V]) Add(k K, v V)

Add puts the value v into the map under the key k. It will overwrite any existing value.

func (*OrderedMap[K, V]) All

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

All returns an iterator that can be used to iterate like over normal maps (with a for range loop).

func (*OrderedMap[K, V]) Build

func (om *OrderedMap[K, V]) Build(k K, v V) *OrderedMap[K, V]

Build adds key k and value v to the ordered map and returns the map itself. This allows elegant building of maps.

func (*OrderedMap[K, V]) Exists

func (om *OrderedMap[K, V]) Exists(k K) bool

func (*OrderedMap[K, V]) Get

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

func (*OrderedMap[K, V]) GetFirst

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

func (*OrderedMap[K, V]) Len

func (om *OrderedMap[K, V]) Len() int

func (*OrderedMap[K, V]) ReplaceFirst

func (om *OrderedMap[K, V]) ReplaceFirst(k K, v V)

Jump to

Keyboard shortcuts

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