com.annimon.stream.operator.ObjLimit Maven / Gradle / Ivy
package com.annimon.stream.operator;
import com.annimon.stream.iterator.LsaIterator;
import java.util.Iterator;
public class ObjLimit extends LsaIterator {
private final Iterator extends T> iterator;
private final long maxSize;
private long index;
public ObjLimit(Iterator extends T> iterator, long maxSize) {
this.iterator = iterator;
this.maxSize = maxSize;
index = 0;
}
@Override
public boolean hasNext() {
return (index < maxSize) && iterator.hasNext();
}
@Override
public T nextIteration() {
index++;
return iterator.next();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy