orderedmap

package
v2.0.0-...-86de2ba Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

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] []entry[K, V]

Map is a simple implementation of column.IterableOrderedMap interface. It is intended to be used as a serdes wrapper for map[K]V and not as a general purpose container.

func Collect

func Collect[K cmp.Ordered, V any](seq func(yield func(K, V) bool)) *Map[K, V]

Collect creates a Map from an iter.Seq2[K,V] iterator.

func CollectFunc

func CollectFunc[K comparable, V any](seq func(yield func(K, V) bool), compare func(K, K) int) *Map[K, V]

CollectFunc creates a Map from an iter.Seq2[K,V] iterator with a custom compare function.

func CollectN

func CollectN[K cmp.Ordered, V any](seq func(yield func(K, V) bool), n int) *Map[K, V]

CollectN creates a Map, pre-sized for n entries, from an iter.Seq2[K,V] iterator.

func CollectNFunc

func CollectNFunc[K comparable, V any](seq func(yield func(K, V) bool), n int, compare func(K, K) int) *Map[K, V]

CollectNFunc creates a Map, pre-sized for n entries, from an iter.Seq2[K,V] iterator with a custom compare function.

func FromMap

func FromMap[M ~map[K]V, K cmp.Ordered, V any](m M) *Map[K, V]

func FromMapFunc

func FromMapFunc[M ~map[K]V, K comparable, V any](m M, compare func(K, K) int) *Map[K, V]

func (*Map[K, V]) All

func (om *Map[K, V]) All(yield func(k K, v V) bool)

All is an iter.Seq[K,V] iterator that yields all key-value pairs in order.

func (*Map[K, V]) Iterator

func (om *Map[K, V]) Iterator() column.MapIterator

Iterator is part of column.IterableOrderedMap interface, it expects to be called by the driver itself.

func (*Map[K, V]) Keys

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

Keys is an iter.Seq[K] iterator that yields all keys in order.

func (*Map[K, V]) Put

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

Put is part of column.IterableOrderedMap interface, it expects to be called by the driver itself, provides no type safety and expects the keys to be given in order. It is recommended to use FromMap and Collect to initialize Map.

func (*Map[K, V]) ToMap

func (om *Map[K, V]) ToMap() map[K]V

func (*Map[K, V]) Values

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

Values is an iter.Seq[V] iterator that yields all values in key order.

Jump to

Keyboard shortcuts

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