T - the element type of the component iterator; this OrderedPairIterator has elements of
type Pair<T,T>public class OrderedPairIterator<T> extends java.lang.Object implements java.util.Iterator<Pair<T,T>>
For example, suppose that the inputs are
[1, 2, 3, 5] and [1, 3, 5, 7, 9].Then the output is
[(1,1), (2,null), (3,3), (5,5), (null,7), (null, 9)].
(This operation is similar to, but not the same as, the operation called "zipping".)
In some cases this is just the right abstraction. But in some cases it's appropriate to use set intersection/difference instead.
| Constructor and Description |
|---|
OrderedPairIterator(java.util.Iterator<T> itor1,
java.util.Iterator<T> itor2)
Create an iterator that returns pairs, where each pair contains has an element from each
iterator and the two elements are equal.
|
OrderedPairIterator(java.util.Iterator<T> itor1,
java.util.Iterator<T> itor2,
java.util.Comparator<T> comparator)
Create an iterator that returns pairs, where each pair contains has an element from each
iterator and the two elements are equal according to the comparator.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext() |
Pair<T,T> |
next() |
void |
remove() |
public OrderedPairIterator(java.util.Iterator<T> itor1, java.util.Iterator<T> itor2)
itor1 - iterator for first elements of pairsitor2 - iterator for second elements of pairspublic OrderedPairIterator(java.util.Iterator<T> itor1, java.util.Iterator<T> itor2, java.util.Comparator<T> comparator)
itor1 - iterator for first elements of pairsitor2 - iterator for second elements of pairscomparator - determines whether two elements are equal and should be paired together