BaseIntFromUntilRepeatingIterator

abstract class BaseIntFromUntilRepeatingIterator<T>(from: Int, toExclusive: Int, offset: Int = 0, step: Int = 1) : Iterator<T> (source)

Returns an Iterator which produces an infinite stream of Ts based on an Int range from (inclusive) until toExclusive considering the given step and offset.

!! No backward compatibility guarantees !! Reuse at your own risk

Since

2.0.0

Parameters

from

The inclusive lower bound of the range (in case offset = 0 also the starting number) -- has to be less than toExclusive.

toExclusive

The non-inclusive upper bound of the range. Put differently. the number which is no longer included in the range, i.e. if the current number + step is greater than toExclusive then the next number is from again -- has to be greater than from.

offset

Influences from which number the range starts where it defines an offset to the from of the range in terms of steps, taking toExclusive and the infinite character of this iterator into account. Following a few examples:

  • startIndex=1, endIndexExclusive=4, step=1, offset=1 => range starts at 2

  • startIndex=1, endIndexExclusive=4, step=2, offset=1 => range starts at 3

  • startIndex=1, endIndexExclusive=4, step=2, offset=2 => range starts at 1 (since 5 is already greater than 4 it starts over at 1)

  • startIndex=1, endIndexExclusive=4, step=2, offset=3 => range starts at 3

step

Defines the step from the current number to the next - must be greater than 0.

Inheritors

Constructors

Link copied to clipboard
constructor(from: Int, toExclusive: Int, offset: Int = 0, step: Int = 1)

Functions

Link copied to clipboard
open fun forEachRemaining(p0: Consumer<in T>)
Link copied to clipboard
abstract fun getElementAt(index: Int): T
Link copied to clipboard
open operator override fun hasNext(): Boolean
Link copied to clipboard
open operator override fun next(): T