public abstract static class Util.Pairwise<T> extends Object
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)
.
DISLOC should be moved to metatools/ops/Iterators or metatools/util !?!?Modifier and Type | Field and Description |
---|---|
protected T |
_last
Internal register for the precedingly visited item.
|
protected Iterator<T> |
it
The iterator which drives the visiting order.
|
protected @Opt ListIterator<T> |
lit
Identic to
it iff the constructor wiht ListIterator has been called. |
Constructor and Description |
---|
Pairwise(Iterable<T> it)
Constructor which does not assume the Iterator to be a ListIterator.
|
Pairwise(Iterator<T> it)
Constructor which does not assume the Iterator to be a ListIterator.
|
Pairwise(ListIterator<T> lit)
Constructor which assumes that the Iterator is a ListIterator.
|
Modifier and Type | Method and Description |
---|---|
void |
first(T t)
Can be overridden by the user to visit the very first element before the first pair
is visited by
pairwise(Object,Object) . |
void |
last(T t)
Can be overridden by the user to visit the very last element after the last pair
is visited by
pairwise(Object,Object) . |
abstract void |
pairwise(T t1,
T t2)
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, executing
first(Object) ,
pairwise(Object,Object) , and last(Object) in this sequential order. |
@Opt protected final @Opt ListIterator<T> lit
it
iff the constructor wiht ListIterator
has been called.
Otherwise null.protected T _last
public Pairwise(Iterable<T> it)
public Pairwise(ListIterator<T> lit)
public void first(T t)
pairwise(Object,Object)
.public void last(T t)
pairwise(Object,Object)
.public abstract void pairwise(T t1, T t2)
Iterator.next()
, so that it "points"
(e.g. with its Iterator.hasNext()
to the successor of the later of both
visited elements.public void process()
first(Object)
,
pairwise(Object,Object)
, and last(Object)
in this sequential order.