Package eu.bandm.tools.ops
Class Iterators.Pairwise<T>
java.lang.Object
eu.bandm.tools.ops.Iterators.Pairwise<T>
- Enclosing class:
- Iterators
Visitor which performs the method
first(Object)
for the first element of an Iterable; afterwards the methodpairwise(Object,Object)
for each pair of adjacent elements, and at last the method last(Object).
These all are performed by invoking process().-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor which does not assume the Iterator to be a ListIterator.protectedConstructor which does not assume the Iterator to be a ListIterator.protectedConstructor which assumes that the Iterator is a ListIterator.protectedPairwise(ListIterator<T> lit) Constructor which assumes that the Iterator is a ListIterator. -
Method Summary
Modifier and TypeMethodDescriptionvoidCan be overridden by the user to visit the very first element before the first pair is visited bypairwise(Object,Object).voidCan be overridden by the user to visit the very last element after the last pair is visited bypairwise(Object,Object).abstract voidMust be overridden by the user to visit the define what to do with each pair of adjacent elements.voidprocess()Central public service provision to visit all wlements in the order of the given (List-) Iterator, executingfirst(Object),pairwise(Object,Object), andlast(Object)in this sequential order.
-
Field Details
-
it
The iterator which drives the visiting order. -
lit
Identic toitiff the constructor wihtListIteratorhas been called. Otherwise null. Can be used by payload code for remove operation, etc. -
_last
Internal register for the precedingly visited item.
-
-
Constructor Details
-
Pairwise
Constructor which does not assume the Iterator to be a ListIterator. -
Pairwise
Constructor which assumes that the Iterator is a ListIterator. -
Pairwise
Constructor which assumes that the Iterator is a ListIterator. -
Pairwise
Constructor which does not assume the Iterator to be a ListIterator.
-
-
Method Details
-
first
Can be overridden by the user to visit the very first element before the first pair is visited bypairwise(Object,Object). -
last
Can be overridden by the user to visit the very last element after the last pair is visited bypairwise(Object,Object). -
pairwise
Must be overridden by the user to visit the define what to do with each pair of adjacent elements. These are visited in the sequential order of the underlying Iterator. On Execution, that has berformed aIterator.next(), so that it "points" (e.g. with itsIterator.hasNext()to the successor of the later of both visited elements. -
process
public void process()Central public service provision to visit all wlements in the order of the given (List-) Iterator, executingfirst(Object),pairwise(Object,Object), andlast(Object)in this sequential order.
-