edu.rice.cs.plt.iter
Class SkipLastIterator<T>

java.lang.Object
  extended by edu.rice.cs.plt.iter.ReadOnlyIterator<T>
      extended by edu.rice.cs.plt.iter.SkipLastIterator<T>
All Implemented Interfaces:
Composite, java.util.Iterator<T>

public class SkipLastIterator<T>
extends ReadOnlyIterator<T>
implements Composite

An iterator that skips the last element of a nested iterator. Since it must read ahead to check if the current element is the last, remove is not supported.


Constructor Summary
SkipLastIterator(java.util.Iterator<? extends T> i)
           
 
Method Summary
 int compositeHeight()
          Get the maximum path length from this node to a leaf.
 int compositeSize()
          Get the number of nodes in the tree rooted at this node.
 boolean hasNext()
           
static
<T> SkipLastIterator<T>
make(java.util.Iterator<? extends T> i)
          Call the constructor (allows T to be inferred)
 T next()
           
 
Methods inherited from class edu.rice.cs.plt.iter.ReadOnlyIterator
remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SkipLastIterator

public SkipLastIterator(java.util.Iterator<? extends T> i)
Method Detail

compositeHeight

public int compositeHeight()
Description copied from interface: Composite
Get the maximum path length from this node to a leaf.

Specified by:
compositeHeight in interface Composite

compositeSize

public int compositeSize()
Description copied from interface: Composite
Get the number of nodes in the tree rooted at this node. Always 1 or greater.

Specified by:
compositeSize in interface Composite

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<T>

next

public T next()
Specified by:
next in interface java.util.Iterator<T>

make

public static <T> SkipLastIterator<T> make(java.util.Iterator<? extends T> i)
Call the constructor (allows T to be inferred)