iter

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package iter provides generic constructors and helpers for iterators

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert[From, To any, I c.Iterator[From]](elements I, converter func(From) To) loop.ConvertIter[From, To]

Convert instantiates an iterator that converts elements with a converter and returns them

func Filter

func Filter[T any, I c.Iterator[T]](elements I, filter func(T) bool) loop.FitIter[T]

Filter instantiates an iterator that checks elements by a filter and returns successful ones

func FilterAndConvert

func FilterAndConvert[From, To any, I c.Iterator[From]](elements I, filter func(From) bool, converter func(From) To) loop.ConvertFitIter[From, To]

FilterAndConvert returns a stream that filters source elements and converts them

func FilterAndFlatt

func FilterAndFlatt[From, To any, I c.Iterator[From]](elements I, filter func(From) bool, flattener func(From) []To) *loop.FlattenFitIter[From, To]

FilterAndFlatt filters source elements and extracts slices of 'To' by the 'flattener' function

func First

func First[T any, I c.Iterator[T]](elements I, filter func(T) bool) (T, bool)

First returns the first element that satisfies requirements of the predicate 'filter'

func Flatt

func Flatt[From, To any, I c.Iterator[From]](elements I, flatt func(From) []To) *loop.FlatIter[From, To]

Flatt instantiates an iterator that converts the collection elements into slices and then flattens them to one level

func Group

func Group[T any, K comparable, I c.Iterator[T]](elements I, by func(T) K) stream.Iter[K, T, map[K][]T]

Group transforms iterable elements to the MapPipe based on applying key extractor to the elements

func NotNil

func NotNil[T any, I c.Iterator[*T]](elements I) loop.FitIter[*T]

NotNil instantiates an iterator that filters nullable elements

func Of

func Of[T any](elements ...T) *slice.Iter[T]

Of instantiates an iterator of predefined elements

func Reduce

func Reduce[T any, I c.Iterator[T]](elements I, by func(T, T) T) T

Reduce reduces elements to an one

func ToKV

func ToKV[T, K, V any, IT c.Iterator[T]](elements IT, keyExtractor func(T) K, valExtractor func(T) V) loop.KeyValuer[T, K, V]

ToKV converts a c.Iterator to a kv.KVIterator using key and value extractors

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL