Class CollectionsPlume.RemoveFirstAndLastIterator<T>

java.lang.Object
org.plumelib.util.CollectionsPlume.RemoveFirstAndLastIterator<T>
Type Parameters:
T - the type of elements of the iterator
All Implemented Interfaces:
Iterator<T>
Enclosing class:
CollectionsPlume

public static final class CollectionsPlume.RemoveFirstAndLastIterator<T> extends Object implements Iterator<T>
Returns an iterator just like its argument, except that the first and last elements are removed. They can be accessed via the getFirst() and getLast() methods.
  • Constructor Details

    • RemoveFirstAndLastIterator

      public RemoveFirstAndLastIterator(Iterator<T> itor)
      Create an iterator just like itor, except without its first and last elements.
      Parameters:
      itor - an itorator whose first and last elements to discard
  • Method Details

    • hasNext

      public boolean hasNext(@GuardSatisfied CollectionsPlume.RemoveFirstAndLastIterator<T> this)
      Specified by:
      hasNext in interface Iterator<T>
    • next

      public T next(@GuardSatisfied CollectionsPlume.RemoveFirstAndLastIterator<T> this)
      Specified by:
      next in interface Iterator<T>
    • getFirst

      @Pure public T getFirst()
      Returns the first element of the iterator that was used to construct this. This value is not part of this iterator (unless the original iterator would have returned it multiple times).
      Returns:
      the first element of the iterator that was used to construct this
    • getLast

      @Pure public T getLast()
      Returns the last element of the iterator that was used to construct this. This value is not part of this iterator (unless the original iterator would have returned it multiple times).

      Throws an error unless the RemoveFirstAndLastIterator has already been iterated all the way to its end (so the delegate is pointing to the last element).

      Returns:
      the last element of the iterator that was used to construct this
    • remove

      public void remove(@GuardSatisfied CollectionsPlume.RemoveFirstAndLastIterator<T> this)
      Specified by:
      remove in interface Iterator<T>