omap

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: BSD-3-Clause Imports: 3 Imported by: 1

README

Package omap implements an ordered map[K]V. See the API reference.

Documentation

Overview

Package omap implements in-memory ordered maps. Map[K, V] is suitable for ordered types K, while MapFunc[K, V] supports arbitrary keys and comparison functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

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

A Map is a map[K]V ordered according to K's standard Go ordering. The zero value of a Map is an empty Map ready to use.

func (*Map[K, V]) All

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

All returns an iterator over the map m. If m is modified during the iteration, some keys may not be visited. No keys will be visited multiple times.

func (*Map[K, V]) Delete

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

Delete deletes m[key].

func (*Map[K, V]) DeleteRange added in v1.1.0

func (m *Map[K, V]) DeleteRange(lo, hi K)

DeleteRange deletes m[k] for all keys k satisfying lo ≤ k ≤ hi.

func (*Map[K, V]) Get

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

Get returns the value of m[key] and reports whether it exists.

func (*Map[K, V]) Scan

func (m *Map[K, V]) Scan(lo, hi K) iter.Seq2[K, V]

Scan returns an iterator over the map m limited to keys k satisfying lo ≤ k ≤ hi.

If m is modified during the iteration, some keys may not be visited. No keys will be visited multiple times.

func (*Map[K, V]) Set

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

Set sets m[key] = val.

type MapFunc

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

A MapFunc is a map[K]V ordered according to an arbitrary comparison function. The zero value of a MapFunc is not meaningful since it has no comparison function. Use NewMapFunc to create a MapFunc. A nil *MapFunc, like a nil Go map, can be read but not written and contains no entries.

func NewMapFunc

func NewMapFunc[K, V any](cmp func(K, K) int) *MapFunc[K, V]

NewMapFunc returns a new MapFunc[K, V] ordered according to cmp.

func (*MapFunc[K, V]) All

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

All returns an iterator over the map m. If m is modified during the iteration, some keys may not be visited. No keys will be visited multiple times.

func (*MapFunc[K, V]) Delete

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

Delete deletes m[key].

func (*MapFunc[K, V]) DeleteRange added in v1.1.0

func (m *MapFunc[K, V]) DeleteRange(lo, hi K)

DeleteRange deletes m[k] for all keys k satisfying lo ≤ k ≤ hi.

func (*MapFunc[K, V]) Get

func (m *MapFunc[K, V]) Get(key K) (V, bool)

Get returns the value of m[key] and reports whether it exists.

func (*MapFunc[K, V]) Scan

func (m *MapFunc[K, V]) Scan(lo, hi K) iter.Seq2[K, V]

Scan returns an iterator over the map m limited to keys k satisfying lo ≤ k ≤ hi.

If m is modified during the iteration, some keys may not be visited. No keys will be visited multiple times.

func (*MapFunc[K, V]) Set

func (m *MapFunc[K, V]) Set(key K, val V)

Set sets m[key] = val.

Jump to

Keyboard shortcuts

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