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

gr.james.simplegraph.AbstractIterator Maven / Gradle / Ivy

Go to download

Simple Graph is a graph interface for Java 6 that is designed to expose a very simple API to support working with graphs

The newest version!
package gr.james.simplegraph;

import java.util.Iterator;
import java.util.NoSuchElementException;

abstract class AbstractIterator implements Iterator {
    private T next;

    AbstractIterator() {
        init();
        this.next = computeNext();
    }

    abstract T computeNext();

    abstract void init();

    @Override
    public final boolean hasNext() {
        return next != null;
    }

    @Override
    public final T next() {
        final T r = this.next;
        if (r == null) {
            throw new NoSuchElementException();
        }
        this.next = computeNext();
        return r;
    }

    @Override
    public final void remove() {
        throw new UnsupportedOperationException();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy