FilterIterator

FilterIterator: FilterIterator, hasValue, value, increment, map, chain, print, toList, sum

struct FilterIterator<Input, It, Predicate>: Iterator<Input&>, Printable

Lazily keeps the elements of another iterator that satisfy a predicate. Get one from filter(); collect the results with toList().

FilterIterator

FilterIterator(It source, Predicate include)

Initializes an iterator keeping the source's matching elements.

hasValue

bool hasValue()

Returns true if there are more matching elements.

value

Input& value()

Returns the next matching element.

increment

void increment()

Advances past the current element.

map

MappedIterator<Output, Input, FilterIterator<Input, It, Predicate>, Pred> map<Output, Pred: Output(Input&)>(Pred transform)

Lazily transforms the elements.

MappedIterator<Output, Input, FilterIterator<Input, It, Predicate>, Pred> map<Output, T: Copyable, Pred: Output(T)>(Pred transform)

Lazily transforms the elements.

chain

ChainIterator<Input, FilterIterator<Input, It, Predicate>, 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<Input> toList()

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

sum

Input sum()

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