Documentation ¶
Overview ¶
Package maps provides utilities to work with maps
Index ¶
- func Equals[K comparable, V any](m1, m2 map[K]V, eq func(V, V) bool) bool
- func Filter[K comparable, V any](m map[K]V, p func(K, V) bool) map[K]V
- func FilterInPlace[K comparable, V any](m map[K]V, p func(K, V) bool) map[K]V
- func FilterMap[K1 comparable, V1 any, K2 comparable, V2 any](m map[K1]V1, p func(K1, V1) fp.Option[tuples.Tuple2[K2, V2]]) map[K2]V2
- func FilterMapTuple[K1 comparable, V1 any, K2 comparable, V2 any](m map[K1]V1, p func(K1, V1) (K2, V2, bool)) map[K2]V2
- func Fold[K comparable, V any, R any](m map[K]V, p func(R, K, V) R, initial R) R
- func Map[K1 comparable, V1 any, K2 comparable, V2 any](m map[K1]V1, p func(K1, V1) (K2, V2)) map[K2]V2
- func Reduce[K comparable, V any, R any](m map[K]V, p func(R, K, V) R) R
- func Slice[K comparable, V, R any](m map[K]V, p func(K, V) R) slices.Slice[R]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equals ¶
func Equals[K comparable, V any](m1, m2 map[K]V, eq func(V, V) bool) bool
Equals returns whether 2 maps are equals in values
func Filter ¶ added in v0.5.0
func Filter[K comparable, V any]( m map[K]V, p func(K, V) bool, ) map[K]V
Filter discards those entries from the map that do not match predicate.
func FilterInPlace ¶ added in v0.5.0
func FilterInPlace[K comparable, V any]( m map[K]V, p func(K, V) bool, ) map[K]V
FilterInPlace deletes those entries from the map that do not match predicate.
func FilterMap ¶
func FilterMap[K1 comparable, V1 any, K2 comparable, V2 any]( m map[K1]V1, p func(K1, V1) fp.Option[tuples.Tuple2[K2, V2]], ) map[K2]V2
FilterMap both filters and maps a map. The predicate function should return a fp.Option monad: fp.Some to indicate the entry should be kept. fp.None to indicate the entry should be discarded
func FilterMapTuple ¶ added in v0.5.0
func FilterMapTuple[K1 comparable, V1 any, K2 comparable, V2 any]( m map[K1]V1, p func(K1, V1) (K2, V2, bool), ) map[K2]V2
FilterMapTuple both filters and maps the given map by receiving a predicate which returns mapped values, and a boolean to indicate whether that entry should be kept.
func Fold ¶ added in v0.5.0
func Fold[K comparable, V any, R any]( m map[K]V, p func(R, K, V) R, initial R, ) R
Fold compacts the given map into a single type by taking into account the initial value
func Map ¶
func Map[K1 comparable, V1 any, K2 comparable, V2 any]( m map[K1]V1, p func(K1, V1) (K2, V2), ) map[K2]V2
Map transforms a map into another one, with same or different types
func Reduce ¶ added in v0.5.0
func Reduce[K comparable, V any, R any]( m map[K]V, p func(R, K, V) R, ) R
Reduce compacts the given map into a single type
Types ¶
This section is empty.