maps

package
v0.0.2-0...-11de152 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: BSD-2-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package maps defines various functions useful with maps of any type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add[K comparable, V any](dst, src map[K]V)

Add adds all key/value pairs in src to dst. When a key in src is already present in dst, the value in dst will be overwritten by the value associated with the key in src.

func Clear

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

Clear removes all entries from m, leaving it empty.

func Clone

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

Clone returns a copy of m. This is a shallow clone: the new keys and values are set using ordinary assignment.

func Equal

func Equal[K, V comparable](m1, m2 map[K]V) bool

Equal reports whether two maps contain the same key/value pairs. Values are compared using ==.

func EqualFunc

func EqualFunc[K comparable, V1, V2 any](m1 map[K]V1, m2 map[K]V2, cmp func(V1, V2) bool) bool

EqualFunc is like Equal, but compares values using cmp. Keys are still compared with ==.

func Filter

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

Filter deletes any key/value pairs from m for which keep returns false.

func Keys

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

Keys returns the keys of the map m. The keys will be an indeterminate order.

func Values

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

Values returns the values of the map m. The values will be in an indeterminate order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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