Documentation
¶
Index ¶
- func Clone[T any](src []T) []T
- func Filter[I any](slice []I, f func(index int, value I) (keep bool)) []I
- func FilterOn[I any](slice *[]I, f func(index int) (keep bool))
- func Foreach(slice interface{}, f func(i int, v interface{}))
- func Map[I, O any](input []I, f func(index int, value I) O) []O
- func Reduce[I, V any](slice []I, initReduceValue V, f func(reduceValue V, index int, value I) V) (reduceValue V)
- func ToMap[I any, K comparable, V any](slice []I, kf func(I) K, vf func(I) V) map[K]V
- func ToMapItself[I any, K comparable](slice []I, kf func(I) K) map[K]I
- type KV
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToMap ¶
func ToMap[I any, K comparable, V any](slice []I, kf func(I) K, vf func(I) V) map[K]V
ToMap convert a slice to a map if vf is nil, will try to use elem of slice as value
func ToMapItself ¶ added in v0.2.0
func ToMapItself[I any, K comparable](slice []I, kf func(I) K) map[K]I
ToMapItself convert a slice to a map like ToMap, but the value of map is the elem of slice itself
Types ¶
type KV ¶
type KV[K comparable, V any] struct { Key K Value V }
func KVsOfMap ¶
func KVsOfMap[K comparable, V any](m map[K]V) []KV[K, V]
KVsOfMap return a kv slice from map
Click to show internal directories.
Click to hide internal directories.