maps

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: MIT Imports: 1 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 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[
	M ~map[K]V,
	F ~func(K, V) (T, U),
	K comparable,
	V any,
	T comparable,
	U any,
](m M, f F) map[T]U

Map creates a new map which values mapping from key-value pair of m by function f

func MapTo

func MapTo[
	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

MapTo inserts pairs mapping from key-value pair 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 MaxValue

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

MaxValue 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 MinValue

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

MinValue 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 MinmaxValue

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

MinmaxValue 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