maps

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone[M ~map[K]V, K comparable, V any](m M) M

Clone returns a copy of m

func Copy

func Copy[D, S ~map[K]V, K comparable, V any](dst D, src S)

Copy copies all key/value pairs in src adding them to dst.

func CopyFunc added in v0.2.19

func CopyFunc[
	D ~map[T]U,
	M ~map[K]V,
	F ~func(K, V) (T, U),
	K comparable,
	V any,
	T comparable,
	U any,
](d D, m M, f F) D

CopyFunc inserts pairs mapping from key-value pair of m by function f

func Equal

func Equal[D, S ~map[K]V, K, V comparable](dst D, src S) bool

Equal reports whether two maps contain the same key/value pairs.

func EqualFunc

func EqualFunc[
	D ~map[K]V,
	S ~map[K]U,
	F ~func(V, U) bool,
	K comparable,
	V any,
	U any,
](dst D, src S, f F) bool

EqualFunc is like Equal, but compares values using

func Keys

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

Keys retrieves keys of map

func Map

func Map[
	D ~[]T,
	M ~map[K]V,
	F ~func(K, V) T,
	K comparable,
	V any,
	T any,
](m M, f F) D

Map creates a slice and inserts values of m by function f

func MaxKey

func MaxKey[M ~map[K]V, K constraints.Ordered, V any](m M) K

MaxKey retrieves maxinum key of map

func MaxKeyFunc added in v0.2.19

func MaxKeyFunc[
	M ~map[K]V,
	F ~func(K, V) T,
	K comparable,
	V any,
	T constraints.Ordered,
](m M, f F) T

MaxKeyFunc retrieves maxinum key of map

func MaxValue

func MaxValue[M ~map[K]V, K comparable, V constraints.Ordered](m M) pair.Pair[K, V]

MaxValue retrieves mininum value of map

func MaxValueFunc added in v0.2.19

func MaxValueFunc[
	M ~map[K]V,
	F ~func(K, V) T,
	K comparable,
	V any,
	T constraints.Ordered,
](m M, f F) pair.Pair[K, T]

MaxValueFunc retrieves mininum value of map

func MinKey

func MinKey[M ~map[K]V, K constraints.Ordered, V any](m M) K

MinKey retrieves mininum key of map

func MinKeyFunc added in v0.2.19

func MinKeyFunc[
	M ~map[K]V,
	F ~func(K, V) T,
	K comparable,
	V any,
	T constraints.Ordered,
](m M, f F) T

MinKeyFunc retrieves mininum key of map

func MinValue

func MinValue[M ~map[K]V, K comparable, V constraints.Ordered](m M) pair.Pair[K, V]

MinValue retrieves mininum value of map

func MinValueFunc added in v0.2.19

func MinValueFunc[
	M ~map[K]V,
	F ~func(K, V) T,
	K comparable,
	V any,
	T constraints.Ordered,
](m M, f F) pair.Pair[K, T]

MinValueFunc retrieves mininum value of map

func MinmaxKey

func MinmaxKey[M ~map[K]V, K constraints.Ordered, V any](m M) (min, max K)

MinmaxKey retrieves mininum and maxinum key of map

func MinmaxKeyFunc added in v0.2.19

func MinmaxKeyFunc[
	M ~map[K]V,
	F ~func(K, V) T,
	K comparable,
	V any,
	T constraints.Ordered,
](m M, f F) (min, max T)

MinmaxKeyFunc retrieves mininum and maxinum key of map

func MinmaxValue

func MinmaxValue[M ~map[K]V, K comparable, V constraints.Ordered](m M) (min, max pair.Pair[K, V])

MinmaxValue retrieves mininum and maxinum value of map

func MinmaxValueFunc added in v0.2.19

func MinmaxValueFunc[
	M ~map[K]V,
	F ~func(K, V) T,
	K comparable,
	V any,
	T constraints.Ordered,
](m M, f F) (min, max pair.Pair[K, T])

MinmaxValueFunc retrieves mininum and maxinum value of map

func SumFunc

func SumFunc[
	M ~map[K]V,
	F ~func(K, V) T,
	K comparable,
	V any,
	T constraints.Number | ~string,
](m M, f F) T

SumFunc sums mapped values by function f

func SumKey

func SumKey[
	M ~map[K]V,
	K constraints.Number | ~string,
	V any,
](m M) K

SumKey sums keys of map

func SumValue

func SumValue[
	M ~map[K]V,
	K comparable,
	V constraints.Number | ~string,
](m M) V

SumValue sums values of map

func Values

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

Values retrieves values of map

Types

This section is empty.

Jump to

Keyboard shortcuts

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