Documentation
¶
Overview ¶
Package maputil provides a collection of map functions.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
func Filter[M ~map[K]V, K comparable, V any](m M, f func(K, V) bool) M
Filter returns a new map containing only the elements in the input map m for which the specified function f is true.
func Invert ¶
func Invert[M ~map[K]V, K, V comparable](m M) map[V]K
Invert returns a new map were keys and values are swapped.
func Map ¶
func Map[M ~map[K]V, K, J comparable, V, U any](m M, f func(K, V) (J, U)) map[J]U
Map returns a new map that contains each of the elements of the input map m mutated by the specified function.
func Reduce ¶
func Reduce[M ~map[K]V, K comparable, V, U any](m M, init U, f func(K, V, U) U) U
Reduce applies the reducing function f to each element of the input map m, and returns the value of the last call to f. The first parameter of the reducing function f is initialized with init.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.