Documentation
¶
Overview ¶
Package maps defines various functions useful with maps of any type.
Index ¶
- func Add[K comparable, V any](dst, src map[K]V)
- func Clear[K comparable, V any](m map[K]V)
- func Clone[K comparable, V any](m map[K]V) map[K]V
- func Equal[K, V comparable](m1, m2 map[K]V) bool
- func EqualFunc[K comparable, V1, V2 any](m1 map[K]V1, m2 map[K]V2, cmp func(V1, V2) bool) bool
- func Filter[K comparable, V any](m map[K]V, keep func(K, V) bool)
- func Keys[K comparable, V any](m map[K]V) []K
- func Values[K comparable, V any](m map[K]V) []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add[K comparable, V any](dst, src map[K]V)
Add adds all key/value pairs in src 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 Clear ¶
func Clear[K comparable, V any](m map[K]V)
Clear removes all entries from m, leaving it empty.
func Clone ¶
func Clone[K comparable, V any](m map[K]V) map[K]V
Clone returns a copy of m. This is a shallow clone: the new keys and values are set using ordinary assignment.
func Equal ¶
func Equal[K, V comparable](m1, m2 map[K]V) bool
Equal reports whether two maps contain the same key/value pairs. Values are compared using ==.
func EqualFunc ¶
func EqualFunc[K comparable, V1, V2 any](m1 map[K]V1, m2 map[K]V2, cmp func(V1, V2) bool) bool
EqualFunc is like Equal, but compares values using cmp. Keys are still compared with ==.
func Filter ¶
func Filter[K comparable, V any](m map[K]V, keep func(K, V) bool)
Filter deletes any key/value pairs from m for which keep returns false.
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 an indeterminate order.
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.
Types ¶
This section is empty.