StrideIterator<E> constructor

StrideIterator<E>(
  1. Iterable<E> iterable,
  2. int stepSize, [
  3. int startIndex = 0
])

Constructs an object of type StrideIterator.

  • iterable: An iterable with entries of type E.
  • stepSize: The iteration stride (step size). Must be larger than zero.
  • startIndex: If startIndex is a valid list index then the first element returned by the getter current (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;