Documentation
¶
Overview ¶
Package maputils provides utilities for working with Go maps, providing functional transformations and map operations.
See README.md for details.
Index ¶
- func IsSubMap[K comparable, V any](sub, super map[K]V, eq func(a, b V) bool) bool
- func Join[K comparable, V any](left, right map[K]V, dup func(K, *V, *V) V) map[K]V
- func JoinOrError[K comparable, V any](left, right map[K]V, dup func(K, *V, *V) (V, error)) (map[K]V, error)
- func MapKeys[KIn, KOut comparable, V any](input map[KIn]V, f func(KIn) KOut) map[KOut]V
- func MapValues[K comparable, VIn, VOut any](input map[K]VIn, f func(K, VIn) VOut) map[K]VOut
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSubMap ¶
func IsSubMap[K comparable, V any](sub, super map[K]V, eq func(a, b V) bool) bool
IsSubMap checks if the 'sub' map is a submap of the 'super' map using the provided equality function for values.
func Join ¶
func Join[K comparable, V any](left, right map[K]V, dup func(K, *V, *V) V) map[K]V
Join merges two maps into one. If a key exists in both maps, the provided duplication function is called to resolve the conflict.
func JoinOrError ¶
func JoinOrError[K comparable, V any](left, right map[K]V, dup func(K, *V, *V) (V, error)) (map[K]V, error)
JoinOrError merges two maps into one. If a key exists in both maps, the provided duplication function is called to resolve the conflict.
func MapKeys ¶
func MapKeys[KIn, KOut comparable, V any](input map[KIn]V, f func(KIn) KOut) map[KOut]V
MapKeys applies the given function to each key of the input map and returns a new map with the transformed keys and original values.
func MapValues ¶
func MapValues[K comparable, VIn, VOut any](input map[K]VIn, f func(K, VIn) VOut) map[K]VOut
MapValues applies the given function to each value of the input map and returns a new map with the original keys and transformed values.
Types ¶
This section is empty.