diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-08 22:39:59 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-08 22:39:59 -0300 |
| commit | c82e3b3b2de0633317ec8fc85925e91422820597 (patch) | |
| tree | 96567416ce23c5ce85601f9cedc3a94bb1c55cba /BJC-Utils2/src/main/java/bjc/utils/data/CircularIterator.java | |
| parent | b3ac1c8690c3e14c879913e5dcc03a5f5e14876e (diff) | |
Start splitting into maven modules
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/CircularIterator.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/data/CircularIterator.java | 81 |
1 files changed, 0 insertions, 81 deletions
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 <E> - * The type of the iterable. - */ -public class CircularIterator<E> implements Iterator<E> { - /* - * The iterable, and our current iterator into it. - */ - private Iterable<E> source; - private Iterator<E> 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<E> 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<E> 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(); - } -} |
