edu.rice.cs.plt.iter
Class NoDuplicatesIterator<T>
java.lang.Object
edu.rice.cs.plt.iter.ReadOnlyIterator<T>
edu.rice.cs.plt.iter.NoDuplicatesIterator<T>
- All Implemented Interfaces:
- Composite, java.util.Iterator<T>
public class NoDuplicatesIterator<T>
- extends ReadOnlyIterator<T>
- implements Composite
An Iterator that returns each value only once. Values are compared via equals() and
hashed in order to detect duplicates. A set of previously-seen values is maintained, which
requires space linear in the number of times next() has been invoked.
|
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
|
make(java.util.Iterator<? extends T> i)
Call the constructor (allows T to be inferred) |
T |
next()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NoDuplicatesIterator
public NoDuplicatesIterator(java.util.Iterator<? extends T> i)
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> NoDuplicatesIterator<T> make(java.util.Iterator<? extends T> i)
- Call the constructor (allows
T to be inferred)