Package eu.bandm.tools.util.java
Class Iterators.Pairwise<T>
java.lang.Object
eu.bandm.tools.util.java.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
-
Constructor Summary
ModifierConstructorDescriptionprotected
Constructor which does not assume the Iterator to be a ListIterator.protected
Constructor which does not assume the Iterator to be a ListIterator.protected
Constructor which assumes that the Iterator is a ListIterator.protected
Pairwise
(ListIterator<T> lit) Constructor which assumes that the Iterator is a ListIterator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Can be overridden by the user to visit the very first element before the first pair is visited bypairwise(Object,Object)
.void
Can be overridden by the user to visit the very last element after the last pair is visited bypairwise(Object,Object)
.abstract void
Must be overridden by the user to visit the define what to do with each pair of adjacent elements.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.
-
Field Details
-
it
The iterator which drives the visiting order. -
lit
Identic toit
iff the constructor wihtListIterator
has 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.
-