All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 iterator;
    private final long maxSize;
    private long index;

    public ObjLimit(Iterator 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