Documentation
¶
Overview ¶
Package maps contains the generic functions for maps.
Index ¶
- func Clear[M ~map[K]V, K comparable, V any](m M)
- func Clone[M ~map[K]V, K comparable, V any](m M) M
- func Contains[K comparable](m map[K]struct{}, slc []K) bool
- func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2)
- 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 Clear ¶ added in v0.4.5
func Clear[M ~map[K]V, K comparable, V any](m M)
Clear removes all entries from m, leaving it empty.
func Clone ¶ added in v0.4.5
func Clone[M ~map[K]V, K comparable, V any](m M) M
Clone returns a copy of m. This is a shallow clone: the new keys and values are set using ordinary assignment.
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 Copy ¶ added in v0.4.5
func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2)
Copy copies all key/value pairs in src adding them to dst. When a key in src is already present in dst, the value in dst will be overwritten by the value associated with the key in src.
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.