maputil

package
v0.55.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy[T1 comparable, T2 any](m map[T1]T2) map[T1]T2

Copy returns a shallow copy of the given map.

func CountFunc

func CountFunc[T1 comparable, T2 any](m map[T1]T2, f func(T2) bool) int

CountFunc returns the number of elements in the map that satisfy the predicate f.

func Filter

func Filter[T1 comparable, T2 any](m map[T1]T2, f func(T2) bool) map[T1]T2

Filter returns a shallow copy of the given map with items that satisfy the predicate f.

func Keys

func Keys[T1 comparable, T2 any](m map[T1]T2) []T1

Keys returns the slice of keys for the given map.

func MapValues

func MapValues[T1 comparable, T2, T3 any](m map[T1]T2, f func(T2) T3) map[T1]T3

MapValues returns a new map with the values of the given map transformed by the function f.

func Merge

func Merge[T1 comparable, T2 any](m1, m2 map[T1]T2) map[T1]T2

Merge returns a new map that contains all the elements of the given maps.

func Select

func Select[T1 comparable, T2 any](m map[T1]T2, kk []T1) (map[T1]T2, error)

Select returns a shallow copy of the given map with items that satisfy the predicate f and will fail when key is not present.

func Slice

func Slice[T1 comparable, T2 any](m map[T1]T2) []T2

Slice returns map values as a slice.

func SortedKeys

func SortedKeys[T1 comparable, T2 any](m map[T1]T2, sort func([]T1)) []T1

SortedKeys returns the slice of keys for the given map, sorted using given sorting function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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