Class Iterators.Pairwise<T>

java.lang.Object
eu.bandm.tools.util.java.Iterators.Pairwise<T>
Enclosing class:
Iterators

public abstract static class Iterators.Pairwise<T> extends Object
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
    Modifier and Type
    Field
    Description
    protected T
    Internal register for the precedingly visited item.
    protected final Iterator<T>
    The iterator which drives the visiting order.
    protected final @Opt ListIterator<T>
    Identic to it iff the constructor wiht ListIterator has been called.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    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
    Constructor which assumes that the Iterator is a ListIterator.
  • Method Summary

    Modifier and Type
    Method
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • it

      protected final Iterator<T> it
      The iterator which drives the visiting order.
    • lit

      @Opt protected final @Opt ListIterator<T> lit
      Identic to it iff the constructor wiht ListIterator has been called. Otherwise null. Can be used by payload code for remove operation, etc.
    • _last

      protected T _last
      Internal register for the precedingly visited item.
  • Constructor Details

    • Pairwise

      protected Pairwise(Iterable<T> it)
      Constructor which does not assume the Iterator to be a ListIterator.
    • Pairwise

      protected Pairwise(List<T> it)
      Constructor which assumes that the Iterator is a ListIterator.
    • Pairwise

      protected Pairwise(ListIterator<T> lit)
      Constructor which assumes that the Iterator is a ListIterator.
    • Pairwise

      protected Pairwise(Iterator<T> it)
      Constructor which does not assume the Iterator to be a ListIterator.
  • Method Details

    • first

      public 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).
    • last

      public 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).
    • pairwise

      public 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. These are visited in the sequential order of the underlying Iterator. On Execution, that has berformed a Iterator.next(), so that it "points" (e.g. with its Iterator.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, executing first(Object), pairwise(Object,Object), and last(Object) in this sequential order.