Documentation ¶
Overview ¶
Package maps contains the generic functions for maps.
Index ¶
- func Contains[K comparable](m map[K]struct{}, slc []K) bool
- func Filter[M ~map[K]V, K comparable, V any](m M, fn func(K, V) bool) M
- func FilterInPlace[M ~map[K]V, K comparable, V any](m M, fn func(K, V) bool) M
- func Intersect[K comparable](maps ...map[K]struct{}) []K
- func Keys[K comparable, V any](m map[K]V) []K
- func KeysFunc[K comparable, V, R any](m map[K]V, fn func(K) R) []R
- func Map[K comparable, V any, K1 comparable, V1 any](m map[K]V, fn func(K, V) (K1, V1)) map[K1]V1
- func ToSlice[K comparable, V any, R any](m map[K]V, fn func(K, V) R) []R
- func Values[K comparable, V any](m map[K]V) []V
- func ValuesFunc[K comparable, V, R any](m map[K]V, fn func(V) R) []R
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[K comparable](m map[K]struct{}, slc []K) bool
Contains reports whether m keys contains all the elements of the slice slc.
func Filter ¶
func Filter[M ~map[K]V, K comparable, V any](m M, fn func(K, V) bool) M
Filter returns a map containing all the elements of m that satisfy fn.
func FilterInPlace ¶
func FilterInPlace[M ~map[K]V, K comparable, V any](m M, fn func(K, V) bool) M
FilterInPlace applies the function fn to each element of the map and returns an old map with the filtered results.
func Intersect ¶
func Intersect[K comparable](maps ...map[K]struct{}) []K
Intersect returns a list of keys contained in both maps.
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
Keys returns the keys of the map m. The keys will be in an indeterminate order.
func KeysFunc ¶
func KeysFunc[K comparable, V, R any](m map[K]V, fn func(K) R) []R
KeysFunc applies the function fn to each key of the map m and returns a new slice with the results. The keys will be in an indeterminate order.
func Map ¶
func Map[K comparable, V any, K1 comparable, V1 any](m map[K]V, fn func(K, V) (K1, V1)) map[K1]V1
Map applies the function fn to each element of the map and returns a new map with the results.
func ToSlice ¶
func ToSlice[K comparable, V any, R any](m map[K]V, fn func(K, V) R) []R
ToSlice applies the function fn to each element of the map and returns a new slice with the results.
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
Values returns the values of the map m. The values will be in an indeterminate order.
func ValuesFunc ¶
func ValuesFunc[K comparable, V, R any](m map[K]V, fn func(V) R) []R
ValuesFunc applies the function fn to each value of the map m and returns a new slice with the results. The values will be in an indeterminate order.
Types ¶
This section is empty.