MappedIterator

MappedIterator: MappedIterator, hasValue, value, increment, map, filter, chain, print, toList, sum

struct MappedIterator<Output, Input, It, Transform>: Iterator<Output&>, Printable

Lazily transforms the elements of another iterator. Get one from map(); collect the results with toList().

MappedIterator

MappedIterator(It source, Transform transform)

Initializes an iterator transforming the source's elements.

hasValue

bool hasValue()

Returns true if there are more elements.

value

Output& value()

Returns the next transformed element.

increment

void increment()

Advances to the next element.

map

MappedIterator<Output2, Output, MappedIterator<Output, Input, It, Transform>, Pred> map<Output2, Pred: Output2(Output&)>(Pred transform)

Lazily transforms the elements.

MappedIterator<Output2, Output, MappedIterator<Output, Input, It, Transform>, Pred> map<Output2, T: Copyable, Pred: Output2(T)>(Pred transform)

Lazily transforms the elements.

filter

FilterIterator<Output, MappedIterator<Output, Input, It, Transform>, Pred> filter<Pred: bool(Output&)>(Pred include)

Lazily keeps the elements satisfying the predicate.

FilterIterator<Output, MappedIterator<Output, Input, It, Transform>, Pred> filter<T: Copyable, Pred: bool(T)>(Pred include)

Lazily keeps the elements satisfying the predicate.

chain

ChainIterator<Output, MappedIterator<Output, Input, It, Transform>, Other> chain<Other>(Other other)

Lazily appends another iterator's elements.

print

void print(OutputStream& stream)

Prints the remaining values in list form, e.g. [1, 2, 3].

toList

List<Output> toList()

Collects the remaining elements into a list by copying them; only sound for Copyable elements.

sum

Output sum()

Returns the sum of the remaining elements, or zero if there are none.