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

com.annimon.stream.operator.ObjIterate Maven / Gradle / Ivy

The newest version!
package com.annimon.stream.operator;

import com.annimon.stream.function.UnaryOperator;
import com.annimon.stream.iterator.LsaIterator;

public class ObjIterate extends LsaIterator {

    private final UnaryOperator op;
    private T current;

    public ObjIterate(T seed, UnaryOperator op) {
        this.op = op;
        current = seed;
    }

    @Override
    public boolean hasNext() {
        return true;
    }

    @Override
    public T nextIteration() {
        final T old = current;
        current = op.apply(current);
        return old;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy