ChainIterator
ChainIterator: ChainIterator, hasValue, value, increment, chain, map, filter, print, toList, sum
struct ChainIterator<Element, First, Second>: Iterator<Element&>, Printable
Lazily concatenates two iterators: yields all of the first's elements, then all of the second's. Get one from chain(); collect with toList().
ChainIterator
ChainIterator(First first, Second second)Initializes an iterator yielding first's elements, then second's.
hasValue
bool hasValue()Returns true if either iterator has more elements.
value
Element& value()Returns the next element.
increment
void increment()Advances to the next element.
chain
ChainIterator<Element, ChainIterator<Element, First, Second>, Other> chain<Other>(Other other)Lazily appends another iterator's elements.
map
MappedIterator<Output, Element, ChainIterator<Element, First, Second>, Pred> map<Output, Pred: Output(Element&)>(Pred transform)Lazily transforms the elements.
MappedIterator<Output, Element, ChainIterator<Element, First, Second>, Pred> map<Output, T: Copyable, Pred: Output(T)>(Pred transform)Lazily transforms the elements.
filter
FilterIterator<Element, ChainIterator<Element, First, Second>, Pred> filter<Pred: bool(Element&)>(Pred include)Lazily keeps the elements satisfying the predicate.
FilterIterator<Element, ChainIterator<Element, First, Second>, Pred> filter<T: Copyable, Pred: bool(T)>(Pred include)Lazily keeps the elements satisfying the predicate.
void print(OutputStream& stream)Prints the remaining values in list form, e.g. [1, 2, 3].
toList
List<Element> toList()Collects the remaining elements into a list by copying them; only sound for Copyable elements.
sum
Element sum()Returns the sum of the remaining elements, or zero if there are none.