Documentation
¶
Overview ¶
Package goiterators provides basic definitions and operations related to iterators over sequences.
Index ¶
- func ForEach[T any](iter Iterator[T], fn func(T) error) error
- func ForEachAsync[T any](iter Iterator[T], fn func(T) error) error
- func ForEachAsyncCtx[T any](ctx context.Context, iter Iterator[T], fn func(context.Context, T) error) error
- func IForEach[T any](iter Iterator[T], fn func(int, T) error) error
- func IForEachAsync[T any](iter Iterator[T], fn func(int, T) error) error
- func IForEachAsyncCtx[T any](ctx context.Context, iter Iterator[T], fn func(context.Context, int, T) error) error
- type Iterator
- func Filter[T any](iterator Iterator[T], fn func(T) bool) Iterator[T]
- func FilterAsync[T any](iter Iterator[T], fn func(T) bool) Iterator[T]
- func FilterAsyncCtx[T any](ctx context.Context, iter Iterator[T], ...) Iterator[T]
- func FlatMap[T, U any](iterator Iterator[T], fn func(T) iter.Seq[U]) Iterator[U]
- func FlatMapAsync[T, U any](iterator Iterator[T], fn func(T) iter.Seq[U]) Iterator[U]
- func FlatMapAsyncCtx[T, U any](ctx context.Context, iterator Iterator[T], ...) Iterator[U]
- func IFilter[T any](iter Iterator[T], fn func(int, T) bool) Iterator[T]
- func IFilterAsync[T any](iter Iterator[T], fn func(int, T) bool) Iterator[T]
- func IFilterAsyncCtx[T any](ctx context.Context, iter Iterator[T], ...) Iterator[T]
- func IFlatMap[T, U any](iter Iterator[T], fn func(int, T) iter.Seq[U]) Iterator[U]
- func IFlatMapAsync[T, U any](iterator Iterator[T], fn func(int, T) iter.Seq[U]) Iterator[U]
- func IFlatMapAsyncCtx[T, U any](ctx context.Context, iter Iterator[T], ...) Iterator[U]
- func IMap[T, U any](iter Iterator[T], fn func(int, T) U) Iterator[U]
- func IMapAsync[T any, U any](iter Iterator[T], fn func(int, T) U) Iterator[U]
- func IMapAsyncCtx[T any, U any](ctx context.Context, iter Iterator[T], ...) Iterator[U]
- func Map[T any, U any](iterator Iterator[T], fn func(T) U) Iterator[U]
- func MapAsync[T any, U any](iter Iterator[T], fn func(T) U) Iterator[U]
- func MapAsyncCtx[T any, U any](ctx context.Context, iter Iterator[T], fn func(context.Context, T) (U, error)) Iterator[U]
- func NewAsyncIterator[T any](dataIn <-chan T) Iterator[T]
- func NewAsyncIteratorErr[T any](dataIn <-chan Result[T]) Iterator[T]
- func NewIterator[T any](next iter.Seq2[int, T]) Iterator[T]
- func NewIteratorErr[T any](next iter.Seq2[T, error]) Iterator[T]
- func NewIteratorFromSlice[T any](slice []T) Iterator[T]
- func Take[T any](iter Iterator[T], n int) Iterator[T]
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForEachAsync ¶ added in v0.0.5
ForEachAsync applies the function to each item with index in parallel
func ForEachAsyncCtx ¶ added in v0.0.5
func ForEachAsyncCtx[T any](ctx context.Context, iter Iterator[T], fn func(context.Context, T) error) error
ForEachAsyncCtx applies the function to each item with index in parallel with context cancellation
func IForEach ¶ added in v0.0.5
IForEach applies the provided function to each item in the iterator with index
func IForEachAsync ¶ added in v0.0.5
IForEachAsync applies the function to each item with index in parallel
Types ¶
type Iterator ¶
type Iterator[T any] interface { Next(yield func(T) bool) INext(yield func(int, T) bool) Err() error }
Iterator provides sequential access to items with optional error handling
func FilterAsync ¶
FilterAsync returns only items that satisfy the predicate function in parallel
func FilterAsyncCtx ¶ added in v0.0.3
func FilterAsyncCtx[T any](ctx context.Context, iter Iterator[T], fn func(context.Context, T) (bool, error)) Iterator[T]
FilterAsyncCtx returns only items that satisfy the predicate function in parallel with context cancellation
func FlatMapAsync ¶
FlatMapAsync transforms each item into multiple results in parallel
func FlatMapAsyncCtx ¶ added in v0.0.3
func FlatMapAsyncCtx[T, U any](ctx context.Context, iterator Iterator[T], fn func(context.Context, T) (iter.Seq[U], error)) Iterator[U]
FlatMapAsyncCtx transforms each item into multiple results in parallel with context cancellation
func IFilter ¶ added in v0.0.2
IFilter returns only items that satisfy the predicate function with index
func IFilterAsync ¶ added in v0.0.2
IFilterAsync returns only items that satisfy the predicate function with index in parallel
func IFilterAsyncCtx ¶ added in v0.0.3
func IFilterAsyncCtx[T any](ctx context.Context, iter Iterator[T], fn func(context.Context, int, T) (bool, error)) Iterator[T]
IFilterAsyncCtx returns only items that satisfy the predicate function with index in parallel with context cancellation
func IFlatMap ¶ added in v0.0.5
IFlatMap transforms each item into multiple results using iter.Seq with index
func IFlatMapAsync ¶ added in v0.0.2
IFlatMapAsync transforms each item into multiple results with index in parallel
func IFlatMapAsyncCtx ¶ added in v0.0.3
func IFlatMapAsyncCtx[T, U any](ctx context.Context, iter Iterator[T], fn func(context.Context, int, T) (iter.Seq[U], error)) Iterator[U]
IFlatMapAsyncCtx transforms each item into multiple results with index in parallel with context cancellation
func IMapAsync ¶ added in v0.0.2
IMapAsync transforms each item using the provided function with index in parallel
func IMapAsyncCtx ¶ added in v0.0.3
func IMapAsyncCtx[T any, U any](ctx context.Context, iter Iterator[T], fn func(context.Context, int, T) (U, error)) Iterator[U]
IMapAsyncCtx transforms each item using the provided function with index in parallel with context cancellation
func MapAsyncCtx ¶ added in v0.0.3
func MapAsyncCtx[T any, U any](ctx context.Context, iter Iterator[T], fn func(context.Context, T) (U, error)) Iterator[U]
MapAsyncCtx transforms each item using the provided function in parallel with context cancellation
func NewAsyncIterator ¶
NewAsyncIterator creates an async iterator from a channel of values
func NewAsyncIteratorErr ¶
NewAsyncIteratorErr creates an async iterator from a channel of Results
func NewIterator ¶
NewIterator creates an iterator from a standard Go iter.Seq2[int, T]
func NewIteratorErr ¶
NewIteratorErr creates an iterator that handles errors from iter.Seq2[T, error]
func NewIteratorFromSlice ¶
NewIteratorFromSlice creates an iterator from a slice
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
async-algorithms
command
|
|
|
basic-usage
command
|
|
|
context-cancellation
command
|
|
|
error-handling
command
|
|
|
foreach
command
|
|
|
indexed-operations
command
|
|
|
mixed-operations
command
|
|
|
sync-algorithms
command
|