Package org.plumelib.util
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 Summary
ConstructorDescriptionRemoveFirstAndLastIterator
(Iterator<T> itor) Create an iterator just likeitor
, except without its first and last elements. -
Method Summary
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
-
Constructor Details
-
RemoveFirstAndLastIterator
Create an iterator just likeitor
, 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) -
next
-
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
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)
-