From 2f6a7807f7180fb467e3d06f2af4263a45759c28 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 13 Apr 2020 18:44:24 -0400 Subject: Cleanup pass Pass to do some cleanups --- src/main/java/bjc/inflexion/QueuedIterator.java | 59 ++++++++++++++----------- 1 file changed, 32 insertions(+), 27 deletions(-) (limited to 'src/main/java/bjc/inflexion/QueuedIterator.java') diff --git a/src/main/java/bjc/inflexion/QueuedIterator.java b/src/main/java/bjc/inflexion/QueuedIterator.java index ab4a447..0dc98a1 100644 --- a/src/main/java/bjc/inflexion/QueuedIterator.java +++ b/src/main/java/bjc/inflexion/QueuedIterator.java @@ -6,10 +6,11 @@ import java.util.Iterator; /** * An iterator that supports queuing elements after/before the current iterator; - * + * * @author bjculkin * - * @param The type of element this iterator iterates over + * @param + * The type of element this iterator iterates over */ public class QueuedIterator implements Iterator { private Iterator cur; @@ -18,7 +19,7 @@ public class QueuedIterator implements Iterator { /** * Static method for constructing iterators. - * + * * @return A queued iterator. */ public static QueuedIterator queued() { @@ -27,9 +28,9 @@ public class QueuedIterator implements Iterator { /** * Static method for constructing iterators. - * + * * @param itrs - * The iterators to use. + * The iterators to use. * @return A queued iterator over the provided iterators. */ @SafeVarargs @@ -39,9 +40,9 @@ public class QueuedIterator implements Iterator { /** * Static method for constructing iterators. - * + * * @param itrs - * The iterables to use. + * The iterables to use. * @return A queued iterator over the provided iterables. */ @SafeVarargs @@ -58,9 +59,9 @@ public class QueuedIterator implements Iterator { /** * Create a new queued iterator with a set of initial sources. - * + * * @param inits - * The set of initial iterators to use. + * The set of initial iterators to use. */ @SafeVarargs public QueuedIterator(Iterator... inits) { @@ -73,9 +74,9 @@ public class QueuedIterator implements Iterator { /** * Create a new queued iterator with a set of initial sources. - * + * * @param inits - * The set of initial iterables to use. + * The set of initial iterables to use. */ @SafeVarargs public QueuedIterator(Iterable... inits) { @@ -88,9 +89,9 @@ public class QueuedIterator implements Iterator { /** * Add a new iterator who we will iterate through first. - * + * * @param itr - * The iterator to go through first. + * The iterator to go through first. */ public void before(Iterator itr) { pending.push(cur); @@ -100,38 +101,39 @@ public class QueuedIterator implements Iterator { /** * Add a new iterable who we will iterate through first. - * + * * @param itr - * The iterable to go through first. + * The iterable to go through first. */ public void before(Iterable itr) { before(itr.iterator()); } - + /** * Add a new iterator who we will iterate through next. - * + * * @param itr - * The iterator to go through next. + * The iterator to go through next. */ public void after(Iterator itr) { pending.push(itr); } + /** * Add a new iterable who we will iterate through next. - * + * * @param itr - * The iterable to go through next. + * The iterable to go through next. */ public void after(Iterable itr) { after(itr.iterator()); } - + /** * Add a new iterator who we will iterate through last. - * + * * @param itr - * The iterator to go through last. + * The iterator to go through last. */ public void last(Iterator itr) { pending.add(itr); @@ -139,17 +141,19 @@ public class QueuedIterator implements Iterator { /** * Add a new iterable who we will iterate through last. - * + * * @param itr - * The iterable to go through last. + * The iterable to go through last. */ public void last(Iterable itr) { last(itr.iterator()); } + @Override public boolean hasNext() { while (cur == null || !cur.hasNext()) { - if (pending.isEmpty()) return false; + if (pending.isEmpty()) + return false; cur = pending.pop(); } @@ -160,7 +164,8 @@ public class QueuedIterator implements Iterator { @Override public E next() { while (cur == null || !cur.hasNext()) { - if (pending.isEmpty()) return null; + if (pending.isEmpty()) + return null; cur = pending.pop(); } -- cgit v1.2.3