net.sf.jga.util
Class UniqueIterator<T>
java.lang.Object
net.sf.jga.util.UniqueIterator<T>
- All Implemented Interfaces:
- java.lang.Iterable<T>, java.util.Iterator<T>
public class UniqueIterator<T>
- extends java.lang.Object
- implements java.util.Iterator<T>, java.lang.Iterable<T>
Iterator that will not return the same element twice in succession.
Copyright © 2003 David A. Hall
- Author:
- David A. Hall
|
Constructor Summary |
UniqueIterator(java.util.Iterator<? extends T> base)
Builds a UniqueIterator for the given base iterator, using a test based
on the equals() method of type T. |
UniqueIterator(java.util.Iterator<? extends T> base,
BinaryFunctor<T,T,java.lang.Boolean> eq)
Builds a UniqueIterator for the given base iterator that uses the given
predicate to compare adjacent elements. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UniqueIterator
public UniqueIterator(java.util.Iterator<? extends T> base)
- Builds a UniqueIterator for the given base iterator, using a test based
on the equals() method of type T.
UniqueIterator
public UniqueIterator(java.util.Iterator<? extends T> base,
BinaryFunctor<T,T,java.lang.Boolean> eq)
- Builds a UniqueIterator for the given base iterator that uses the given
predicate to compare adjacent elements. The predicate should return true
if the adjacent elements are the same.
- Throws:
java.lang.IllegalArgumentException - if either argument is null
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator in interface java.lang.Iterable<T>
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>
Copyright © 2002-2005 David A. Hall. All Rights Reserved.