Documentation ¶
Overview ¶
Utility iterator functions.
Index ¶
- func FromSlice[T any](s []T) c.Iterator[T]
- func Map[I any, O any](it c.Iterator[I], to func(item I) O) c.Iterator[O]
- func Range(end int) c.Iterator[int]
- func Reduce[I any, O any](it c.Iterator[I], start O, reducer func(acc O, item I) O) O
- func Sum[T constraints.Ordered](it c.Iterator[T]) T
- func XRange(start, end, step int) c.Iterator[int]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Map ¶
Map will map values of type `I` from to type `O` through the `to` mapper function.
Example:
v := collection.Vec[int]{1, 2, 3, 4, 5, 6, 7, 8, 9} number_iterator := v.Iter().Filter(func(item int) string { return item%2 == 0}) iter.Map(number_iterator, func(item int) string { return fmt.Sprint("number ", item) }). ForEach(func(item string) { fmt.Prinln(item) })
This is a workaround to implement `Map` as currently methods cannot have type paramters.
func Reduce ¶
Reduce will reduce the values through the reducer
This is a workaround to implement `Reduce` as currently methods cannot have type paramters.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.