Documentation
¶
Overview ¶
Package maputil provides basic utility functions for generic maps.
Index ¶
- func Difference[M ~map[K]V, K comparable, V any](a, b M) M
- func Filter[M ~map[K]V, K comparable, V any](m M, p ...func(k K, v V) bool) M
- func Keys[M ~map[K]V, K comparable, V any](m M, p ...func(k K, v V) bool) []K
- func Map[AS ~map[AK]AV, BS ~map[BK]BV, AK, BK comparable, AV, BV any](as AS, fn func(ak AK, av AV) (BK, BV)) BS
- func Values[M ~map[K]V, K comparable, V any](m M, p ...func(k K, v V) bool) []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Difference ¶ added in v1.3.0
func Difference[M ~map[K]V, K comparable, V any](a, b M) M
Difference returns all the elements in 'a' that are not in 'b'.
func Filter ¶
func Filter[M ~map[K]V, K comparable, V any](m M, p ...func(k K, v V) bool) M
Filter removes all key/value pairs in the given map that do not match the given predicates.
NOTE: Providing no predicates results in a no-op.
func Keys ¶
func Keys[M ~map[K]V, K comparable, V any](m M, p ...func(k K, v V) bool) []K
Keys returns the keys from the given map.
NOTE: When provided with one or more predicates, only returns keys which match all predicates.
func Map ¶ added in v1.4.0
func Map[AS ~map[AK]AV, BS ~map[BK]BV, AK, BK comparable, AV, BV any](as AS, fn func(ak AK, av AV) (BK, BV)) BS
Map applies the given function to each element of the provided map.
func Values ¶
func Values[M ~map[K]V, K comparable, V any](m M, p ...func(k K, v V) bool) []V
Values returns the values from the given map.
NOTE: When provided with one or more predicates, only returns values which match all predicates.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.