maps

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreMapsEqual

func AreMapsEqual[K comparable, V comparable](a map[K]V, b map[K]V) bool

AreMapsEqual returns true if the two maps are equal. Two maps are equal if they have the same keys and values.

func ArrayToMapInterface

func ArrayToMapInterface[T comparable](list []T) map[T]struct{}

func GetSortedKeys

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

GetSortedKeys returns the keys of the map in sorted order.

func InvertMustHaveDistinctValues

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

InvertMustHaveDistinctValues returns a new map with the keys and values of the input map swapped. If there are duplicate values in the input map, the method will panic.

func MergeAllMapsMustHaveDistinctKeys

func MergeAllMapsMustHaveDistinctKeys[K comparable, V any](maps ...map[K]V) map[K]V

MergeAllMapsMustHaveDistinctKeys merges all the maps into a single map. Panics if there are duplicate keys.

func ShallowCopy

func ShallowCopy[K comparable, V any](originalMap map[K]V) map[K]V

Copy returns a shallow copy of originalMap. Parameters:

  • originalMap: The map to be copied.

Returns:

A new map containing all the keys and values from originalMap.

Types

This section is empty.

Jump to

Keyboard shortcuts

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