maps

package
v1.3.1 Latest Latest
Warning

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

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

Documentation

Overview

Package maputil provides basic utility functions for generic maps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Difference added in v1.3.0

func Difference[M ~map[K]V, K comparable, V any](a, b M) M

Difference returns all the elements in 'a' that are not in 'b'.

func Filter

func Filter[M ~map[K]V, K comparable, V any](m M, p ...func(k K, v V) bool) M

Filter removes all key/value pairs in the given map that do not match the given predicates.

NOTE: Providing no predicates results in a no-op.

func Keys

func Keys[M ~map[K]V, K comparable, V any](m M, p ...func(k K, v V) bool) []K

Keys returns the keys from the given map.

NOTE: When provided with one or more predicates, only returns keys which match all predicates.

func Values

func Values[M ~map[K]V, K comparable, V any](m M, p ...func(k K, v V) bool) []V

Values returns the values from the given map.

NOTE: When provided with one or more predicates, only returns values which match all predicates.

Types

This section is empty.

Jump to

Keyboard shortcuts

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