maps

package
v0.0.0-...-1ed8eff Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOccurence

func AddOccurence[T comparable](m map[T]int, e T, count int)

AddOccurence adds an occurrence to a map.

func Append

func Append[K comparable, V any](m map[K][]V, k K, v V)

Append appends the element to the slice in the map. If the key is not present, a new slice is created. If the key is present, the element is appended to the existing slice. If the map is nil, it panics.

func Contains

func Contains[K comparable, V any](m map[K]V, k K) bool

Contains checks if a map contains a key.

func Filter

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

Filter filters the values of a map.

func ForEach

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

ForEach iterates over the elements of a map.

func Keys

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

Keys returns the keys of a map.

func Map

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

Map maps the values of a map.

func MapValues

func MapValues[K comparable, V1, V2 any](m map[K]V1, f func(V1) V2) map[K]V2

MapValues maps the values of a map.

func Merge

func Merge[K comparable, V any](m1, m2 map[K]V) map[K]V

Merge merges two maps into a new map. If a key is present in both maps, the value from the second map is used.

func Occurrences

func Occurrences[T comparable](s []T) map[T]int

Occurrences creates a map with the occurrences of the elements in a slice.

func Sum

func Sum[K comparable, V types.Summable](m map[K]V) V

Sum sums the values of a map.

func ToSlice

func ToSlice[K comparable, V, T any](m map[K]V, f func(K, V) T) []T

ToSlice converts a map to a slice of key-value pairs.

func Values

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

Values returns the values of a map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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