Documentation
¶
Index ¶
- func AddOccurence[T comparable](m map[T]int, e T, count int)
- func Append[K comparable, V any](m map[K][]V, k K, v V)
- func Contains[K comparable, V any](m map[K]V, k K) bool
- func Filter[K comparable, V any](m map[K]V, f func(K, V) bool) map[K]V
- func ForEach[K comparable, V any](m map[K]V, f func(K, V))
- func Keys[K comparable, V any](m map[K]V) []K
- func Map[K1, K2 comparable, V1, V2 any](m map[K1]V1, f func(K1, V1) (K2, V2)) map[K2]V2
- func MapValues[K comparable, V1, V2 any](m map[K]V1, f func(V1) V2) map[K]V2
- func Merge[K comparable, V any](m1, m2 map[K]V) map[K]V
- func Occurrences[T comparable](s []T) map[T]int
- func Sum[K comparable, V types.Summable](m map[K]V) V
- func ToSlice[K comparable, V, T any](m map[K]V, f func(K, V) T) []T
- func Values[K comparable, V any](m map[K]V) []V
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 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 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.
Types ¶
This section is empty.