Details
-
New Feature
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
ZippingIterator provides a way to simulatenously iterate over multiple iterators of the same-type.
The proposed pair iterator allows simultaneously iterating over two iterators of different type, like the example below:
Iterator<L> leftIterator = ...;
Iterator<R> rightIterator = ...;
PairIterator<L,R> pairIterator = PairIterator.of(leftIterator, rightIterator);
while (pairIterator.hasNext()) {
ImmutablePair<L,R> item = pairIterator.next();
...
}
Another convenience could be to use an Iterable for easy for-each constructs.
List<Integer> studentIds = ... List<String> studentNames = ... for (PairedItem<Integer, String> items : IterableUtils.pairedIterable(studentIds, studentNames) { Integer studentId = item.getLeft(); String studentName = item.getRight(); ... }