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.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) T
    The next object that this iterator will return.
    (package private) T
    The first object yielded by the wrapped iterator.
    (package private) Iterator<T>
    The wrapped iterator.
    (package private) T
    A marker object, distinct from any object that the iterator can return.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an iterator just like itor, except without its first and last elements.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the first element of the iterator that was used to construct this.
    Returns the last element of the iterator that was used to construct this.
    boolean
     
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining
  • Field Details

    • itor

      Iterator<T> itor
      The wrapped iterator.
    • nothing

      T nothing
      A marker object, distinct from any object that the iterator can return.
    • first

      T first
      The first object yielded by the wrapped iterator.
    • current

      T current
      The next object that this iterator will return.
  • 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>