summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/data/CircularIterator.java
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-04-07 21:03:53 -0400
committerBen Culkin <scorpress@gmail.com>2020-04-07 21:03:53 -0400
commit002516bd03b2ea3f731c8139c9a5f716902ab702 (patch)
tree4b45260e0b411dd070ae5d2f45e8f2795bf91b79 /base/src/main/java/bjc/utils/data/CircularIterator.java
parentd6afd99961aacd6ce915629773723cb6c6e145a7 (diff)
Finish remove utils.data
utils.data now lives in the esodata project; not in this one
Diffstat (limited to 'base/src/main/java/bjc/utils/data/CircularIterator.java')
-rw-r--r--base/src/main/java/bjc/utils/data/CircularIterator.java79
1 files changed, 0 insertions, 79 deletions
diff --git a/base/src/main/java/bjc/utils/data/CircularIterator.java b/base/src/main/java/bjc/utils/data/CircularIterator.java
deleted file mode 100644
index 9af4d87..0000000
--- a/base/src/main/java/bjc/utils/data/CircularIterator.java
+++ /dev/null
@@ -1,79 +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) {
- return curElm;
- }
-
- curr = source.iterator();
- }
-
- curElm = curr.next();
-
- return curElm;
- }
-
- @Override
- public void remove() {
- curr.remove();
- }
-}