StrideIterator<E> constructor
Constructs an object of type StrideIterator.
iterable
: An iterable with entries of typeE
.stepSize
: The iteration stride (step size). Must be larger than zero.startIndex
: IfstartIndex
is a valid list index then the first element returned by the gettercurrent
(after initially advancing the iterator) will be:iterable.elementAt(startIndex)
.
Implementation
StrideIterator(Iterable<E> iterable, int stepSize, [int startIndex = 0])
: _iterable = iterable,
stepSize = stepSize <= 0 ? 1 : stepSize,
_length = iterable.length,
_position = startIndex < 0 ? -stepSize : startIndex - stepSize;