Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Inverse ¶
func Inverse[K comparable, V comparable](in map[K]V) map[V]K
func Keys
deprecated
func Keys[M ~map[K]V, K comparable, V any](m M) []K
Keys returns all keys from the map as a slice.
Deprecated: Use slices.Collect(maps.Keys(m)) from the standard library instead. This function will be removed in a future version.
Example (StandardLibrary) ¶
Example showing how to use the standard library maps.Keys with slices.Collect. This is the recommended approach going forward.
m := map[int]string{1: "one", 2: "two", 3: "three"}
// New way: use standard library
keys := slices.Collect(stdmaps.Keys(m))
slices.Sort(keys)
// Output can't be guaranteed due to map iteration order,
// but this demonstrates the pattern
_ = keys
func Values
deprecated
func Values[M ~map[K]V, K comparable, V any](m M) []V
Values returns all values from the map as a slice.
Deprecated: Use slices.Collect(maps.Values(m)) from the standard library instead. This function will be removed in a future version.
Example (StandardLibrary) ¶
Example showing how to use the standard library maps.Values with slices.Collect. This is the recommended approach going forward.
m := map[int]string{1: "one", 2: "two", 3: "three"}
// New way: use standard library
values := slices.Collect(stdmaps.Values(m))
slices.Sort(values)
// Output can't be guaranteed due to map iteration order,
// but this demonstrates the pattern
_ = values
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.