Documentation
¶
Index ¶
- func Clone[K comparable, V any, M ~map[K]V](m M) M
- func Collect[K comparable, V any](s iter.Seq[MapEntry[K, V]]) map[K]V
- func DeleteBy[K comparable, V any](x map[K]V, f func(K, V) bool)
- func Entries[K comparable, V any, M ~map[K]V](m M) iter.Seq[MapEntry[K, V]]
- func Equal[K comparable, V comparable, M1 ~map[K]V, M2 ~map[K]V](lhs M1, rhs M2) bool
- func EqualBy[K comparable, V1, V2 any, M1 ~map[K]V1, M2 ~map[K]V2](lhs M1, rhs M2, equal func(V1, V2) bool) bool
- func Filter[K comparable, V any, M ~map[K]V](m M, f func(K, V) bool) M
- func FilterMap[K comparable, V any, M ~map[K]V, X comparable, Y any, N ~map[X]Y](m M, f func(K, V) (X, Y, bool)) N
- func ForEach[K comparable, V any, M ~map[K]V](m M, f func(K, V))
- func Invert[K comparable, V comparable, M1 ~map[K]V, M2 ~map[V]K](m M1) M2
- func Keys[K comparable, V any, M ~map[K]V](m M) iter.Seq[K]
- func Map[K, X comparable, V, Y any, M ~map[K]V](m M, f func(K, V) (X, Y)) map[X]Y
- func MapKey[K, X comparable, V any, M ~map[K]V](m M, f func(K) X) map[X]V
- func MapValue[K comparable, V, X any, M ~map[K]V](m M, f func(V) X) map[K]X
- func MergeFunc[K comparable, V any, M ~map[K]V](ms iter.Seq[M], onConflict func(V, V) V) M
- func MergeKeep[K comparable, V any, M ~map[K]V](ms iter.Seq[M]) M
- func MergeOverwrite[K comparable, V any, M ~map[K]V](ms iter.Seq[M]) M
- func Values[K comparable, V any, M ~map[K]V](m M) iter.Seq[V]
- type MapEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶ added in v0.4.0
func Clone[K comparable, V any, M ~map[K]V](m M) M
func Collect ¶ added in v0.5.0
func Collect[K comparable, V any](s iter.Seq[MapEntry[K, V]]) map[K]V
func DeleteBy ¶ added in v0.4.1
func DeleteBy[K comparable, V any](x map[K]V, f func(K, V) bool)
func Entries ¶ added in v0.4.0
func Entries[K comparable, V any, M ~map[K]V](m M) iter.Seq[MapEntry[K, V]]
Entries returns all entry of a map.
func Equal ¶ added in v0.4.0
func Equal[K comparable, V comparable, M1 ~map[K]V, M2 ~map[K]V](lhs M1, rhs M2) bool
func EqualBy ¶ added in v0.4.0
func EqualBy[K comparable, V1, V2 any, M1 ~map[K]V1, M2 ~map[K]V2](lhs M1, rhs M2, equal func(V1, V2) bool) bool
func Filter ¶ added in v0.5.0
func Filter[K comparable, V any, M ~map[K]V](m M, f func(K, V) bool) M
Filter keep those elements which match the given predicate function.
func FilterMap ¶ added in v0.5.0
func FilterMap[K comparable, V any, M ~map[K]V, X comparable, Y any, N ~map[X]Y](m M, f func(K, V) (X, Y, bool)) N
FilterMap keep those elements which match the given predicate function and map to new type elements.
func ForEach ¶ added in v0.5.0
func ForEach[K comparable, V any, M ~map[K]V](m M, f func(K, V))
ForEach iter over the map, and call the udf on each k-v pair.
func Invert ¶ added in v0.5.0
func Invert[K comparable, V comparable, M1 ~map[K]V, M2 ~map[V]K](m M1) M2
Invert maps k-v to v-k, when conflict, the back element will overwrite the previous one.
func Keys ¶ added in v0.4.0
func Keys[K comparable, V any, M ~map[K]V](m M) iter.Seq[K]
Keys return key slice of a map.
func Map ¶ added in v0.5.0
func Map[K, X comparable, V, Y any, M ~map[K]V](m M, f func(K, V) (X, Y)) map[X]Y
Map map each k-v pair to x-y pair into a new map.
func MapKey ¶ added in v0.5.0
func MapKey[K, X comparable, V any, M ~map[K]V](m M, f func(K) X) map[X]V
func MapValue ¶ added in v0.5.0
func MapValue[K comparable, V, X any, M ~map[K]V](m M, f func(V) X) map[K]X
func MergeFunc ¶ added in v0.5.0
func MergeFunc[K comparable, V any, M ~map[K]V](ms iter.Seq[M], onConflict func(V, V) V) M
MergeFunc merge many maps and solve conflict use a udf.
UDF has signature `func(V, V) V`, first param is previous element, second is visit element, return element will be used.
func MergeKeep ¶ added in v0.5.0
func MergeKeep[K comparable, V any, M ~map[K]V](ms iter.Seq[M]) M
MergeKeep merge many maps and keep first value when conflict occrured.
func MergeOverwrite ¶ added in v0.5.0
func MergeOverwrite[K comparable, V any, M ~map[K]V](ms iter.Seq[M]) M
MergeOverwrite merge many maps and keep last value when conflict occrured.