maps

package
v1.4.25 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureNotNil

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

EnsureNotNil ensures a given map is not nil. Returns a new empty (but non-nil) map if the original map was nil.

func MatchesFilters added in v0.1.10

func MatchesFilters[K comparable, V comparable](
	kv map[K]V,
	inclusion map[K][]V,
	exclusion map[K][]V,
) bool

MatchesFilters returns true if the given map matches the given inclusion and exclusion filters. This requires that the map's values are comparable.

func Reverse added in v1.4.12

func Reverse[K, V comparable](m map[K]V) map[V]K

Reverse returns a new map where the keys and values are reversed from the original input map. This is useful when we want to index a particular search on both keys and values e.g. mapping of public identifiers to internal identifiers and viceversa.

Note that if values are not unique in the input map, the retured map will only have a key-value pair for the last ocurrence of the value (which is the key in the generated map) in the input map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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