Documentation
¶
Index ¶
- func GetAny[Map ~map[K]V, K comparable, V any](m Map) (K, V, bool)
- func GetAnyValue[Map ~map[K]V, K comparable, V any](m Map) (K, V)
- func Inverse[Map ~map[K]V, K, V comparable](m Map) map[V]K
- func KeyRefSlice[Map ~map[K]V, K comparable, V any](m Map) []*K
- func KeySet[Map ~map[K]V, K comparable, V any](m Map) set.Set[K]
- func KeySlice[Map ~map[K]V, K comparable, V any](m Map) []K
- func KeysByValue[Map ~map[K]V, K, V comparable](m Map) map[V][]K
- func Map[Map ~map[KIn]VIn, KIn comparable, VIn any, KOut comparable, VOut any](m Map, f func(KIn, VIn) (KOut, VOut)) map[KOut]VOut
- func Pop[Map ~map[K]V, K comparable, V any](m Map) (K, V, bool)
- func PopValue[Map ~map[K]V, K comparable, V any](m Map) (K, V)
- func SortedKeySlice[Map ~map[K]V, K cmp.Ordered, V any](m Map) []K
- func SortedKeySliceFunc[Map ~map[K]V, K comparable, V any](m Map, cmp func(a, b K) int) []K
- func SortedValueSlice[Map ~map[K]V, K comparable, V cmp.Ordered](m Map) []V
- func SortedValueSliceFunc[Map ~map[K]V, K comparable, V any](m Map, cmp func(a, b V) int) []V
- func ValueRefSlice[Map ~map[K]V, K comparable, V any](m Map) []*V
- func ValueSet[Map ~map[K]V, K, V comparable](m Map) set.Set[V]
- func ValueSlice[Map ~map[K]V, K comparable, V any](m Map) []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAny ¶
func GetAny[Map ~map[K]V, K comparable, V any](m Map) (K, V, bool)
GetAny returns an arbitrary key-value pair from the map and whether the map is non-empty.
func GetAnyValue ¶
func GetAnyValue[Map ~map[K]V, K comparable, V any](m Map) (K, V)
GetAnyValue returns an arbitrary key-value pair from the map, ignoring the boolean.
func Inverse ¶
func Inverse[Map ~map[K]V, K, V comparable](m Map) map[V]K
Inverse returns a new map with the keys and values swapped. If multiple keys map to the same value, only one will be present in the result.
func KeyRefSlice ¶
func KeyRefSlice[Map ~map[K]V, K comparable, V any](m Map) []*K
KeyRefSlice returns a slice of pointers to all keys in the map.
func KeySet ¶
func KeySet[Map ~map[K]V, K comparable, V any](m Map) set.Set[K]
KeySet returns a set of all keys in the map.
func KeySlice ¶
func KeySlice[Map ~map[K]V, K comparable, V any](m Map) []K
KeySlice returns a slice of all keys in the map.
func KeysByValue ¶
func KeysByValue[Map ~map[K]V, K, V comparable](m Map) map[V][]K
KeysByValue returns a new map that groups keys by their values.
func Map ¶
func Map[Map ~map[KIn]VIn, KIn comparable, VIn any, KOut comparable, VOut any](m Map, f func( KIn, VIn, ) (KOut, VOut)) map[KOut]VOut
Map applies the given function to all map key-value pairs, returning a new map with the resulting values.
func Pop ¶
func Pop[Map ~map[K]V, K comparable, V any](m Map) (K, V, bool)
Pop removes and returns an arbitrary key-value pair from the map. It also returns a boolean indicating whether a pair was popped. If the map is empty, it returns the zero values for the key and value and false.
func PopValue ¶
func PopValue[Map ~map[K]V, K comparable, V any](m Map) (K, V)
PopValue removes and returns an arbitrary key-value pair from the map. It's a convenience wrapper around Pop that ignores the boolean return value.
func SortedKeySlice ¶
SortedKeySlice returns a slice of all keys in the map, sorting them at the end.
func SortedKeySliceFunc ¶
func SortedKeySliceFunc[Map ~map[K]V, K comparable, V any](m Map, cmp func(a, b K) int) []K
SortedKeySliceFunc returns a slice of all keys in the map, sorting them at the end by the given function.
func SortedValueSlice ¶
func SortedValueSlice[Map ~map[K]V, K comparable, V cmp.Ordered](m Map) []V
SortedValueSlice returns a slice of all values in the map.
func SortedValueSliceFunc ¶
func SortedValueSliceFunc[Map ~map[K]V, K comparable, V any](m Map, cmp func(a, b V) int) []V
SortedValueSliceFunc returns a slice of all values in the map sorted by the given function.
func ValueRefSlice ¶
func ValueRefSlice[Map ~map[K]V, K comparable, V any](m Map) []*V
ValueRefSlice returns a slice of pointers to all values in the map.
func ValueSet ¶
func ValueSet[Map ~map[K]V, K, V comparable](m Map) set.Set[V]
ValueSet returns a set of all values in the map.
func ValueSlice ¶
func ValueSlice[Map ~map[K]V, K comparable, V any](m Map) []V
ValueSlice returns a slice of all values in the map.
Types ¶
This section is empty.