Documentation
¶
Overview ¶
Package xmaps provides more generic functions in the spirit of the maps package.
Index ¶
- func HasKey[M ~map[K]V, K comparable, V any](m M, k K) bool
- func Init[M ~map[K]V, K comparable, V any](m M) M
- func SetDefault[M ~map[K]V, K comparable, V any](m M, k K, defaultValue V) V
- func Sorted[M ~map[K]V, K cmp.Ordered, V any](m M) iter.Seq2[K, V]
- func SortedKeys[M ~map[K]V, K cmp.Ordered, V any](m M) []K
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasKey ¶
func HasKey[M ~map[K]V, K comparable, V any](m M, k K) bool
HasKey reports whether m[k] exists.
func Init ¶
func Init[M ~map[K]V, K comparable, V any](m M) M
Init clears m and returns m if m != nil or returns a new map otherwise.
func SetDefault ¶
func SetDefault[M ~map[K]V, K comparable, V any](m M, k K, defaultValue V) V
SetDefault returns m[k] or if m does not contain k, then SetDefault sets m[k] to defaultValue and returns defaultValue.
func SortedKeys ¶
SortedKeys returns a slice of the map's keys in sorted order.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.