maps

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[M ~map[K]V, K comparable, V any](m M, pred func(k K, v V) bool) bool

All returns true if pred returns true for every entry of the input map.

func Any

func Any[M ~map[K]V, K comparable, V any](m M, pred func(k K, v V) bool) bool

Any returns true if pred returns true for any entry of the input map.

func FMap

func FMap[M ~map[K]V, K, L comparable, V, W any](m M, fn func(k K, v V) (L, W, bool)) iter.Seq2[L, W]

FMap returns a sequence of values computed by invoking fn on each entry of the input map and returning only mapped values for with fn returns true.

func Filter

func Filter[M ~map[K]V, K comparable, V any](m M, fn func(k K, v V) bool) iter.Seq2[K, V]

Filter returns a sequence of values computed by invoking fn on each entry of the input map and returning only those entries for with fn returns true.

func Map

func Map[M ~map[K]V, K, L comparable, V, W any](m M, fn func(k K, v V) (L, W)) iter.Seq2[L, W]

Map invokes fn on each value in the input map and returns the results.

func Pairs

func Pairs[M ~map[K]V, K comparable, V any](m M) iter.Seq[fx.Pair[K, V]]

Pairs returns a sequence of (key, value) entries in m represented as fx.Pairs.

Equivalent to fx.PackAll(maps.All(m)).

func Reduce

func Reduce[M ~map[K]V, K comparable, V, U any](m M, init U, fn func(acc U, k K, v V) U) U

Reduce calls fn on each entry of the input map, passing in the current value of the accumulator with each invocation and updating the accumulator to the result of fn after each invocation.

func TryCollect

func TryCollect[K comparable, V any](it iter.Seq2[fx.Pair[K, V], error]) (map[K]V, error)

TryCollect attempts to collect the key-value pairs in the input sequence into a map. If any pair in the input contains a non-nil error, TryCollect halts and returns the collected map up to that point (excluding the value returned with the error) and the error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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