mapseqs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT-0 Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Remap added in v0.16.0

func Remap[
	Map ~map[KeyIn]ValueIn,
	EntryOut interface{ Unpack() (KeyOut, ValueOut) },
	KeyIn, KeyOut comparable,
	ValueIn, ValueOut any,
](m Map, fn func(KeyIn, ValueIn) seqs.Seq[EntryOut]) map[KeyOut]ValueOut

Remap returns a map obtained by passing entries of the specified map to the specified transformation function and folding the resulting entries into a map.

func RemapIter added in v0.16.0

func RemapIter[
	Map ~map[KeyIn]ValueIn,
	KeyIn, KeyOut comparable,
	ValueIn, ValueOut any,
](m Map, fn func(KeyIn, ValueIn) iter.Seq2[KeyOut, ValueOut]) map[KeyOut]ValueOut

RemapIter is the same as Remap but the transformation function returns an iter.Seq2 instead of a seqs.Seq.

func ToMap

func ToMap[
	Seq seqs.Seq[Entry],
	Entry interface{ Unpack() (Key, Value) },
	Key comparable,
	Value any,
](seq Seq) map[Key]Value

func ToMapWith

func ToMapWith[Seq seqs.Seq[Entry], Entry any, Key comparable, Value any, Unpack ~func(Entry) (Key, Value)](seq Seq, unpack Unpack) (m map[Key]Value)

func ZipToMap added in v0.16.0

func ZipToMap[KeySeq seqs.Seq[Key], ValueSeq seqs.Seq[Value], Key comparable, Value any](keys KeySeq, values ValueSeq) map[Key]Value

ZipToMap returns a map obtained by zipping the specified sequence of keys and sequence of values.

Types

type MapEntries

type MapEntries[
	Map Mapping[Key, Value],
	Key comparable,
	Value any,
	Entry any,
	Pack ~func(Key, Value) Entry,
] struct {
	Map  Map
	Pack Pack
}

func EntriesOf

func EntriesOf[
	Map Mapping[Key, Value],
	Key comparable,
	Value any,
](
	m Map,
) MapEntries[
	Map,
	Key,
	Value,
	MapEntry[Key, Value],
	func(Key, Value) MapEntry[Key, Value],
]

func EntriesOfWith

func EntriesOfWith[
	Map Mapping[Key, Value],
	Key comparable,
	Value any,
	Entry any,
	Pack ~func(Key, Value) Entry,
](m Map, pack Pack) MapEntries[Map, Key, Value, Entry, Pack]

func KeysOf

func KeysOf[M Mapping[K, V], K comparable, V any](m M) MapEntries[M, K, V, K, func(K, V) K]

func ValuesOf

func ValuesOf[M Mapping[K, V], K comparable, V any](m M) MapEntries[M, K, V, V, func(K, V) V]

func (MapEntries[_, K, V, E, _]) ForEachWhile added in v1.0.0

func (mes MapEntries[_, K, V, E, _]) ForEachWhile(yield func(E) bool)

func (MapEntries[_, _, _, _, _]) Len

func (mes MapEntries[_, _, _, _, _]) Len() int

type MapEntry

type MapEntry[Key, Value any] struct {
	Key   Key
	Value Value
}

func MapEntryFrom

func MapEntryFrom[Key, Value any](key Key, value Value) MapEntry[Key, Value]

func (MapEntry[Key, Value]) Unpack

func (e MapEntry[Key, Value]) Unpack() (Key, Value)

type Mapping

type Mapping[K comparable, V any] interface {
	~map[K]V
}

Jump to

Keyboard shortcuts

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