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, V comparable, M ~map[K]V](m M) map[V]K
- func KeySlice[K comparable, V any, M ~map[K]V](m M) []K
- 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, V) X) map[X]V
- func MapValue[K comparable, V, X any, M ~map[K]V](m M, f func(K, V) X) map[K]X
- func MergeFunc[K comparable, V any, M ~map[K]V](ms iter.Seq[M], onConflict func(key K, prev V, current 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 Retain[K comparable, V any, M ~map[K]V](m M, f func(K, V) bool)
- func ValueSlice[K comparable, V any, M ~map[K]V](m M) []V
- 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
Collect collects iter.Seq into a map
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 as an iter.Seq
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, V comparable, M ~map[K]V](m M) map[V]K
Invert maps k-v to v-k, when key conflict, the back element will overwrite the previous one.
func KeySlice ¶ added in v0.6.0
func KeySlice[K comparable, V any, M ~map[K]V](m M) []K
KeySlice return key slice of a map.
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's iter.Seq 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 call f on each k-v pair and maps 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, V) 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(K, 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(key K, prev V, current V) V) M
MergeFunc merge many maps and solve conflict use an 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 occurred.
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 occurred.
func Retain ¶ added in v0.6.0
func Retain[K comparable, V any, M ~map[K]V](m M, f func(K, V) bool)
func ValueSlice ¶ added in v0.6.0
func ValueSlice[K comparable, V any, M ~map[K]V](m M) []V
ValueSlice return value slice of a map.
Types ¶
type MapEntry ¶ added in v0.4.0
type MapEntry[K, V any] struct { // contains filtered or unexported fields }
MapEntry persist k-v pair of a map.
func EntrySlice ¶ added in v0.6.0
func EntrySlice[K comparable, V any, M ~map[K]V](m M) []MapEntry[K, V]
EntrySlice return entry slice of a map.