
com.annimon.stream.operator.IntRangeClosed Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stream Show documentation
Show all versions of stream Show documentation
Enhancing Java 8 Streams
The newest version!
package com.annimon.stream.operator;
import com.annimon.stream.iterator.PrimitiveIterator;
public class IntRangeClosed extends PrimitiveIterator.OfInt {
private final int endInclusive;
private int current;
private boolean hasNext;
public IntRangeClosed(int startInclusive, int endInclusive) {
this.endInclusive = endInclusive;
current = startInclusive;
hasNext = current <= endInclusive;
}
@Override
public boolean hasNext() {
return hasNext;
}
@Override
public int nextInt() {
if (current >= endInclusive) {
hasNext = false;
return endInclusive;
}
return current++;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy