maputils

package
v0.0.0-...-525d511 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterByKey

func FilterByKey[M ~map[K]V, K comparable, V any](m M, matcher matcher.Matcher[K]) M

func FilterByValue

func FilterByValue[M ~map[K]V, K comparable, V any](m M, matcher matcher.Matcher[V]) M

func FilterKeys

func FilterKeys[M ~map[K]V, K comparable, V any](m M, matcher matcher.Matcher[K]) []V

func FilterValues

func FilterValues[M ~map[K]V, K comparable, V any](m M, matcher matcher.Matcher[V]) []V

func Keys

func Keys[M ~map[K]V, K comparable, V any](m M, cmp ...CompareFunc[K]) []K

Keys provides a list of keys optionally sorted by a CompareFunc.

func MapKeys

func MapKeys[M ~map[K]V, K comparable, V any, TK comparable](in M, m transformer.Transformer[K, TK]) map[TK]V

func OrderedKeys

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

OrderedKeys provides an ordered key list for maps with an ordered key type.

func OrderedValues

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

OrderedValues returns values optionally ordered by ordered keys.

func Transform

func Transform[M ~map[K]V, K comparable, V any, TK comparable, TV any](in M, m Transformer[K, V, TK, TV]) map[TK]TV

func TransformValues

func TransformValues[M ~map[K]V, K comparable, V any, TV comparable](in M, m transformer.Transformer[V, TV]) map[K]TV

func Values

func Values[M ~map[K]V, K comparable, V any](m M, cmp ...CompareFunc[K]) []V

Values returns values optionally ordered by keys.

Types

type CompareFunc

type CompareFunc[E any] func(a, b E) int

type Transformer

type Transformer[K, V, TK, TV any] func(K, V) (TK, TV)

func KeyValueTransformer

func KeyValueTransformer[K, V, TK, TV any](tk transformer.Transformer[K, TK], tv transformer.Transformer[V, TV]) Transformer[K, V, TK, TV]

Jump to

Keyboard shortcuts

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