gmap

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

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

Filter returns a new map containing only the key-value pairs that pass the given predicate function. If the given map is nil, nil is returned.

func Get

func Get[K comparable, V any](m map[K]V, k K, def V) V

Get returns the value of the given key in the given map. If the key does not exist, the default value is returned.

func Keys

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

Keys returns a slice of keys of the given map. The order of the keys is not guaranteed. If the given map is nil, nil is returned.

func Map

func Map[K1, K2 comparable, V1, V2 any](m map[K1]V1, f func(K1, V1) (K2, V2)) map[K2]V2

Map returns a new map containing the results of applying the given function to each key-value pair. If the given map is nil, nil is returned.

func Values

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

Values returns a slice of values of the given map. The order of the values is not guaranteed. If the given map is nil, nil is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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