
com.annimon.stream.operator.IntSample 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 IntSample extends PrimitiveIterator.OfInt {
private final PrimitiveIterator.OfInt iterator;
private final int stepWidth;
public IntSample(PrimitiveIterator.OfInt iterator, int stepWidth) {
this.iterator = iterator;
this.stepWidth = stepWidth;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public int nextInt() {
final int result = iterator.nextInt();
int skip = 1;
while (skip < stepWidth && iterator.hasNext()) {
iterator.nextInt();
skip++;
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy