maps

package
v0.0.0-...-b061da3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyKey

func AnyKey[K comparable, V any](m map[K]V) (K, bool)

AnyKey returns an arbitrary key of the map m. If m is not empty, the second return value is true. If the map is empty, AnyKey returns the zero value of the m's key type and false.

func AnyVal

func AnyVal[K comparable, V any](m map[K]V) (V, bool)

AnyVal returns an arbitrary value of the map m. If m is not empty, the second return value is true. If the map is empty, AnyVal returns the zero value of the m's value type and false.

func Copy

func Copy[K comparable, V any](m map[K]V) map[K]V

func FromSlices

func FromSlices[K comparable, V any](keys []K, vals []V) map[K]V

FromSlices constructs and returns a map from two separate slices of keys and corresponding values. FromSlices panics if the number of keys differs from the number of values.

func IterateSorted

func IterateSorted[K constraints.Ordered, V any](m map[K]V, f func(key K, value V) (cont bool))

func IterateSortedCustom

func IterateSortedCustom[K comparable, V any](m map[K]V, f func(K, V) bool, less func(K, K) bool)

func Keys

func Keys[K comparable, V any](m map[K]V) []K

Keys returns a slice containing all keys of map m in arbitrary order.

func KeysAndValues

func KeysAndValues[K comparable, V any](m map[K]V) ([]K, []V)

KeysAndValues returns a slice containing all keys of map m (in arbitrary order) and a slice containing the corresponding values, in the corresponding order.

statement

keys, values := KeysAndValues(m)

is equivalent to:

keys := Keys(m)
values := ValuesOf(m, keys)

func RemoveAll

func RemoveAll[K comparable, V any](m map[K]V, f func(key K, value V) bool) map[K]V

func SortedKeys

func SortedKeys[K constraints.Ordered, V any](m map[K]V) []K

func Transform

func Transform[Ki comparable, Vi any, Ko comparable, Vo any](mi map[Ki]Vi, f func(Ki, Vi) (Ko, Vo)) map[Ko]Vo

func Values

func Values[K comparable, V any](m map[K]V) []V

Values returns a slice containing all values of map m in arbitrary order.

func ValuesOf

func ValuesOf[K comparable, V any](m map[K]V, keys []K) []V

ValuesOf returns a slice containing the values from map m corresponding to the provided keys, in the same order as the keys.

Types

This section is empty.

Jump to

Keyboard shortcuts

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