maps

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package maps contains the generic functions for maps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[K comparable](m map[K]struct{}, slc []K) bool

Contains reports whether m keys contains all the elements of the slice slc.

func Filter

func Filter[M ~map[K]V, K comparable, V any](m M, fn func(K, V) bool) M

Filter returns a map containing all the elements of m that satisfy fn.

func FilterInPlace

func FilterInPlace[M ~map[K]V, K comparable, V any](m M, fn func(K, V) bool) M

FilterInPlace applies the function fn to each element of the map and returns an old map with the filtered results.

func Intersect

func Intersect[K comparable](maps ...map[K]struct{}) []K

Intersect returns a list of keys contained in both maps.

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 in an indeterminate order.

func KeysFunc

func KeysFunc[K comparable, V, R any](m map[K]V, fn func(K) R) []R

KeysFunc applies the function fn to each key of the map m and returns a new slice with the results. The keys will be in an indeterminate order.

func Map

func Map[K comparable, V any, K1 comparable, V1 any](m map[K]V, fn func(K, V) (K1, V1)) map[K1]V1

Map applies the function fn to each element of the map and returns a new map with the results.

func ToSlice

func ToSlice[K comparable, V any, R any](m map[K]V, fn func(K, V) R) []R

ToSlice applies the function fn to each element of the map and returns a new slice with the results.

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.

func ValuesFunc

func ValuesFunc[K comparable, V, R any](m map[K]V, fn func(V) R) []R

ValuesFunc applies the function fn to each value of the map m and returns a new slice with the results. 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