net.sf.jga.algorithms
Class Unique.UniqueIterator<T>

java.lang.Object
  extended by net.sf.jga.algorithms.Unique.UniqueIterator<T>
All Implemented Interfaces:
java.util.Iterator<T>
Enclosing class:
Unique

public static class Unique.UniqueIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>

Iterator that will not return the same element twice in succession.


Constructor Summary
Unique.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.
Unique.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.
Unique.UniqueIterator(java.util.Iterator<? extends T> base, java.util.Comparator<? super T> comp)
          Builds a UniqueIterator for the given base iterator, using the given comparator.
 
Method Summary
 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

Unique.UniqueIterator

public Unique.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.


Unique.UniqueIterator

public Unique.UniqueIterator(java.util.Iterator<? extends T> base,
                             java.util.Comparator<? super T> comp)
Builds a UniqueIterator for the given base iterator, using the given comparator.


Unique.UniqueIterator

public Unique.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
Method Detail

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-2006 David A. Hall. All Rights Reserved.