xmaps

package
v0.0.0-...-15c7053 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package xmaps provides more generic functions in the spirit of the maps package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Sorted

func Sorted[M ~map[K]V, K cmp.Ordered, V any](m M) iter.Seq2[K, V]

Sorted iterates over a map in sorted order.

func SortedKeys

func SortedKeys[M ~map[K]V, K cmp.Ordered, V any](m M) []K

SortedKeys returns a slice of the map's keys in sorted order.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL