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

solid.stream.FixedSizeStream Maven / Gradle / Ivy

package solid.stream;

import java.util.Iterator;

import solid.functions.Func1;

class FixedSizeStream extends Stream {

    private final int length;
    private final Func1 get;

    public FixedSizeStream(int length, Func1 get) {
        this.length = length;
        this.get = get;
    }

    @Override
    public Iterator iterator() {
        return new ReadOnlyIterator() {

            int index;

            @Override
            public boolean hasNext() {
                return index < length;
            }

            @Override
            public T next() {
                return get.call(index++);
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy