RepeatIterator
RepeatIterator: RepeatIterator, hasValue, value, increment, print, toList, sum
struct RepeatIterator<T: Copyable>: Iterator<T&>, Printable
Lazily repeats a value a number of times without allocating. Get one from repeat(); collect the results with toList().
RepeatIterator
RepeatIterator(T value, int count)Initializes an iterator yielding value count times.
hasValue
bool hasValue()Returns true if there are repetitions remaining.
value
T& value()Returns the repeated value.
increment
void increment()Advances to the next repetition.
void print(OutputStream& stream)Prints the remaining values in list form, e.g. [1, 2, 3].
toList
List<T> toList()Collects the repetitions into a list by copying them; only sound for Copyable elements.
sum
T sum()Returns the sum of the remaining elements, or zero if there are none.