From c82e3b3b2de0633317ec8fc85925e91422820597 Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Sun, 8 Oct 2017 22:39:59 -0300 Subject: Start splitting into maven modules --- .../main/java/bjc/utils/data/CircularIterator.java | 81 ---------------------- 1 file changed, 81 deletions(-) delete mode 100644 BJC-Utils2/src/main/java/bjc/utils/data/CircularIterator.java (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/CircularIterator.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/CircularIterator.java b/BJC-Utils2/src/main/java/bjc/utils/data/CircularIterator.java deleted file mode 100644 index a708eba..0000000 --- a/BJC-Utils2/src/main/java/bjc/utils/data/CircularIterator.java +++ /dev/null @@ -1,81 +0,0 @@ -package bjc.utils.data; - -import java.util.Iterator; - -/** - * An iterator that repeats elements from a provided iterable. - * - * @author EVE - * - * @param - * The type of the iterable. - */ -public class CircularIterator implements Iterator { - /* - * The iterable, and our current iterator into it. - */ - private Iterable source; - private Iterator curr; - - /* - * Our current element. - */ - private E curElm; - - /* - * Should we actually get new iterators, or just repeat the last - * element? - */ - private boolean doCircle; - - /** - * Create a new circular iterator. - * - * @param src - * The iterable to iterate from. - * - * @param circ - * Should we actually do circular iteration, or just - * repeat the terminal element? - */ - public CircularIterator(final Iterable src, final boolean circ) { - source = src; - curr = source.iterator(); - - doCircle = circ; - } - - /** - * Create a new circular iterator that does actual circular iteration. - * - * @param src - * The iterable to iterate from. - */ - public CircularIterator(final Iterable src) { - this(src, true); - } - - @Override - public boolean hasNext() { - // We always have something - return true; - } - - @Override - public E next() { - if (!curr.hasNext()) { - if (doCircle) { - curr = source.iterator(); - } else return curElm; - } - - curElm = curr.next(); - - return curElm; - } - - @Override - public void remove() { - curr.remove(); - } -} -- cgit v1.2.3