public interface RoundRobinIterator<T> extends IterableIterator<T>
Iterator
that returns values in Round-Robin order. Items can be added and removed in O(1) constant time.
This Iterator
will loop continuously.Modifier and Type | Method and Description |
---|---|
void |
add(T value)
Adds a value to the iterator.
|
boolean |
isEmpty()
Returns
true if RoundRobinIterator is empty. |
IterableIterator<T> |
loopIterator()
Starts a loop where you can do one iteration over each element in the iterator starting from the last
element returned by
Iterator.next() . |
static <T> RoundRobinIterator<T> |
newInstance()
Returns a
RoundRobinIterator with no initial values. |
static <T> RoundRobinIterator<T> |
newInstance(java.util.Collection<T> values)
Returns a
RoundRobinIterator with the initial values in values. |
void |
remove(T value)
Removes value from the
Iterator . |
int |
size()
Returns the number of elements in
RoundRobinIterator . |
IterableIterator<T> |
statelessLoopIterator()
Starts a loop where you can do one iteration over each element in the iterator starting from the last
element returned by
Iterator.next() . |
static <T> RoundRobinIterator<T> newInstance()
RoundRobinIterator
with no initial values.static <T> RoundRobinIterator<T> newInstance(java.util.Collection<T> values)
RoundRobinIterator
with the initial values in values.void add(T value)
Iterator.next()
, and
thus will be returned the next time Iterator.next()
is called. This operation is performed in O(1) constant time.
If no values have been added, this value is first.void remove(T value)
Iterator
. This operation is performed in O(1) constant time. It is safe to call
this method while iterating. If this value would have been returned by Iterator.next()
on the next call, the
value after it will now be returned.int size()
RoundRobinIterator
.boolean isEmpty()
true
if RoundRobinIterator
is empty.IterableIterator<T> loopIterator()
Iterator.next()
. The iteration over this loop does affect the Iterator
's position
once the loop ends, meaning the element returned by Iterator.next()
may be different from when you started if you
exit the loop early.
This IterableIterator
is a child of the RoundRobinIterator
that created it, meaning that any
changes on it will affect its parent (such as calling Iterator.remove()
. However, the parent
RoundRobinIterator
should not be used while this IterableIterator
is in use as it may break it.
IterableIterator<T> statelessLoopIterator()
Iterator.next()
. The iteration over this loop does not affect the Iterator
's position
once the loop ends, meaning that the element returned by Iterator.next()
will be the same as what would've been
returned before the loop started (unless that element was removed).
This IterableIterator
is a child of the RoundRobinIterator
that created it, meaning that any
changes on it will affect its parent (such as calling Iterator.remove()
. However, the parent
RoundRobinIterator
should not be used while this IterableIterator
is in use as it may break it.