flabbergast.RamblingIterator Maven / Gradle / Ivy
package flabbergast;
import java.util.Iterator;
import java.util.Stack;
public final class RamblingIterator implements Iterator {
public interface GetNext {
public T ramblingNext(Stack> stack);
}
private Stack> stack = new Stack>();
public RamblingIterator(GetNext first) {
stack.push(first);
}
@Override
public boolean hasNext() {
return !stack.isEmpty();
}
@Override
public T next() {
return stack.pop().ramblingNext(stack);
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy