E
- the element typeF
- the generic typepublic class NestedIterator<E,F>
extends java.lang.Object
implements java.util.Iterator<java.lang.Object[]>
The return value is converted to an array of values where the first value corresponds with the current value of innerIterator and the second value is the current value of outerIterator.
When innerIterator is an instance of NestedIterator the value returned by next() is not an array of 2 values but an array
of 3 values where the last 2 values are the values returned by the innertIterator. This process is recursive so
if there are N NestedIterator nested used as innerIterator of the next one, the return value of the next()
method
of the outermost NestedIterator will be an array of N+1 values where each index represents the Nth iterator
starting from the outermost iterator.
Constructor and Description |
---|
NestedIterator(java.util.Iterator<E> outerIterator,
java.util.Iterator<F> innerIterator)
Creates an instance of a nested iterator to iterate over values of two
iterators so each value of the outer iterator is combined with each one
of the values of the inner iterator.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Checks for next.
|
java.lang.Object[] |
next()
Next.
|
void |
remove()
Removes the.
|
public NestedIterator(java.util.Iterator<E> outerIterator, java.util.Iterator<F> innerIterator)
outerIterator
- the iterator on the left side, values will be returned on index 0 of the arrayinnerIterator
- the iterator on the right side, values will be returned on the index 1 of the arraypublic boolean hasNext()
hasNext
in interface java.util.Iterator<java.lang.Object[]>
public java.lang.Object[] next()
next
in interface java.util.Iterator<java.lang.Object[]>
public void remove()
remove
in interface java.util.Iterator<java.lang.Object[]>
Copyright 2006-2015 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa