public interface RoundRobinKeyValueIterator<K,V> extends IterableIterator<V>
Iterator
that returns values associated with keys 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(K key,
V value)
Adds this key-value pair to the iterator.
|
boolean |
containsKey(K key)
Returns
true if this RoundRobinKeyValueIterator contains a value for this key. |
V |
get(K key)
Returns the value associated with this key.
|
boolean |
isEmpty()
Returns
true if RoundRobinKeyValueIterator is empty. |
IterableIterator<V> |
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 <K,V> RoundRobinKeyValueIterator<K,V> |
newInstance()
Returns a
RoundRobinKeyValueIterator with no initial values. |
static <K,V> RoundRobinKeyValueIterator<K,V> |
newInstance(java.util.Collection<javafx.util.Pair<K,V>> pairs)
Returns a
RoundRobinKeyValueIterator with the initial key-value pairings in pairs. |
V |
remove(K key)
Removes the value associated with key from the
Iterator . |
int |
size()
Returns the number of elements in
RoundRobinKeyValueIterator . |
IterableIterator<V> |
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 <K,V> RoundRobinKeyValueIterator<K,V> newInstance()
RoundRobinKeyValueIterator
with no initial values.static <K,V> RoundRobinKeyValueIterator<K,V> newInstance(java.util.Collection<javafx.util.Pair<K,V>> pairs)
RoundRobinKeyValueIterator
with the initial key-value pairings in pairs.void add(K key, V 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.V remove(K key)
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.boolean containsKey(K key)
true
if this RoundRobinKeyValueIterator
contains a value for this key.V get(K key)
java.lang.IllegalArgumentException
- if this key does not exist.int size()
RoundRobinKeyValueIterator
.boolean isEmpty()
true
if RoundRobinKeyValueIterator
is empty.IterableIterator<V> 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 RoundRobinKeyValueIterator
that created it, meaning
that any changes on it will affect its parent (such as calling Iterator.remove()
. However, the parent
RoundRobinKeyValueIterator
should not be used while this IterableIterator
is in use as it may
break it.
IterableIterator<V> 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 RoundRobinKeyValueIterator
that created it, meaning
that any changes on it will affect its parent (such as calling Iterator.remove()
. However, the parent
RoundRobinKeyValueIterator
should not be used while this IterableIterator
is in use as it may
break it.