package zmap
import "zgo.at/zstd/zmap"
Package zmap implements generic functions for maps.
Index ¶
- func KeyValue[M ~map[K]V, K comparable, V any](m M) []struct { K K V V }
- func Keys[M ~map[K]V, K cmp.Ordered, V any](m M) []K
- func KeysOrdered[M ~map[K]V, K cmp.Ordered, V any](m M) []K
- func LongestKey[M ~map[string]V, V any](m M) ([]string, int)
- func Reverse[K, V comparable](m map[K]V) map[V]K
- func Values[M ~map[K]V, K comparable, V any](m M) []V
Functions ¶
func KeyValue ¶
func KeyValue[M ~map[K]V, K comparable, V any](m M) []struct { K K V V }
KeyValue returns a struct slice with the keys and values.
func Keys ¶
func Keys[M ~map[K]V, K cmp.Ordered, V any](m M) []K
Keys returns an unsorted list of keys of the map.
Deprecated: use slices.Collect(maps.Keys())
func KeysOrdered ¶
func KeysOrdered[M ~map[K]V, K cmp.Ordered, V any](m M) []K
KeysOrdered returns the sorted keys of the map.
func LongestKey ¶
LongestKey returns the longest key in this map and the unsorted list of all keys.
func Reverse ¶
func Reverse[K, V comparable](m map[K]V) map[V]K
Reverse the key and values in a map.
func Values ¶
func Values[M ~map[K]V, K comparable, V any](m M) []V
Values returns the values of the map.
Deprecated: use slices.Collect(maps.Values())
Source Files ¶
old.go zmap.go
- Version
- v0.0.0-20261028170124-7561b8637ff8 (latest)
- Published
- Oct 28, 2026
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 20 minutes ago –
Tools for package owners.