maputil

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: LGPL-2.1 Imports: 0 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package maputil provides a collection of map utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

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

Filter returns a new map containing only the elements in the input map m for which the specified function f is true.

func Invert

func Invert[M ~map[K]V, K, V comparable](m M) map[V]K

Invert returns a new map were keys and values are swapped.

func Map

func Map[M ~map[K]V, K, J comparable, V, U any](m M, f func(K, V) (J, U)) map[J]U

Map returns a new map that contains each of the elements of the input map m mutated by the specified function.

func Reduce

func Reduce[M ~map[K]V, K comparable, V, U any](m M, init U, f func(K, V, U) U) U

Reduce applies the reducing function f to each element of the input map m, and returns the value of the last call to f. The first parameter of the reducing function f is initialized with init.

Types

This section is empty.

Jump to

Keyboard shortcuts

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