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

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

public class TruncatedIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>, Composite

Truncates a given iterator to have at most size elements.


Constructor Summary
TruncatedIterator(java.util.Iterator<? extends T> iter, int size)
           
 
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()
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TruncatedIterator

public TruncatedIterator(java.util.Iterator<? extends T> iter,
                         int size)
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>

remove

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