Documentation ¶
Index ¶
- func AnyKey[K comparable, V any](m map[K]V) (K, bool)
- func AnyVal[K comparable, V any](m map[K]V) (V, bool)
- func Copy[K comparable, V any](m map[K]V) map[K]V
- func FromSlices[K comparable, V any](keys []K, vals []V) map[K]V
- func GetKeys[K comparable, V any](m map[K]V) []K
- func GetKeysAndValues[K comparable, V any](m map[K]V) ([]K, []V)
- func GetSortedKeys[K constraints.Ordered, V any](m map[K]V) []K
- func GetValues[K comparable, V any](m map[K]V) []V
- func GetValuesOf[K comparable, V any](m map[K]V, keys []K) []V
- func IterateSorted[K constraints.Ordered, V any](m map[K]V, f func(key K, value V) (cont bool))
- func IterateSortedCustom[K comparable, V any](m map[K]V, f func(K, V) bool, less func(K, K) bool)
- func RemoveAll[K comparable, V any](m map[K]V, f func(key K, value V) bool) map[K]V
- func Transform[Ki comparable, Vi any, Ko comparable, Vo any](mi map[Ki]Vi, f func(Ki, Vi) (Ko, Vo)) map[Ko]Vo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyKey ¶
func AnyKey[K comparable, V any](m map[K]V) (K, bool)
AnyKey returns an arbitrary key of the map m. If m is not empty, the second return value is true. If the map is empty, AnyKey returns the zero value of the m's key type and false.
func AnyVal ¶
func AnyVal[K comparable, V any](m map[K]V) (V, bool)
AnyVal returns an arbitrary value of the map m. If m is not empty, the second return value is true. If the map is empty, AnyVal returns the zero value of the m's value type and false.
func Copy ¶
func Copy[K comparable, V any](m map[K]V) map[K]V
func FromSlices ¶
func FromSlices[K comparable, V any](keys []K, vals []V) map[K]V
FromSlices constructs and returns a map from two separate slices of keys and corresponding values. FromSlices panics if the number of keys differs from the number of values.
func GetKeys ¶
func GetKeys[K comparable, V any](m map[K]V) []K
GetKeys returns a slice containing all keys of map m in arbitrary order.
func GetKeysAndValues ¶
func GetKeysAndValues[K comparable, V any](m map[K]V) ([]K, []V)
GetKeysAndValues returns a slice containing all keys of map m (in arbitrary order) and a slice containing the corresponding values, in the corresponding order.
statement
keys, values := GetKeysAndValues(m)
is equivalent to:
keys := GetKeys(m) values := GetValuesOf(m, keys)
func GetSortedKeys ¶
func GetSortedKeys[K constraints.Ordered, V any](m map[K]V) []K
func GetValues ¶
func GetValues[K comparable, V any](m map[K]V) []V
GetValues returns a slice containing all values of map m in arbitrary order.
func GetValuesOf ¶
func GetValuesOf[K comparable, V any](m map[K]V, keys []K) []V
GetValuesOf returns a slice containing the values from map m corresponding to the provided keys, in the same order as the keys.
func IterateSorted ¶
func IterateSorted[K constraints.Ordered, V any](m map[K]V, f func(key K, value V) (cont bool))
func IterateSortedCustom ¶
func IterateSortedCustom[K comparable, V any](m map[K]V, f func(K, V) bool, less func(K, K) bool)
func RemoveAll ¶
func RemoveAll[K comparable, V any](m map[K]V, f func(key K, value V) bool) map[K]V
func Transform ¶
func Transform[Ki comparable, Vi any, Ko comparable, Vo any](mi map[Ki]Vi, f func(Ki, Vi) (Ko, Vo)) map[Ko]Vo
Types ¶
This section is empty.