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

de.fluxparticle.utils.chain.ChainIterator Maven / Gradle / Ivy

The newest version!
package de.fluxparticle.utils.chain;

import java.util.Iterator;

/**
 * Created by sreinck on 12.04.17.
 */
public class ChainIterator implements Iterator {

    private Chain chain;

    public ChainIterator(Chain chain) {
        this.chain = chain;
    }

    @Override
    public boolean hasNext() {
        return !chain.isEmpty();
    }

    @Override
    public T next() {
        T head = chain.head();
        chain = chain.tail();
        return head;
    }

    public Chain getChain() {
        return chain;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy