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

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

public static class Unique.UniqueIterable<T>
extends java.lang.Object
implements java.lang.Iterable<T>

Produces iterators that will not return the same element twice in succession.

Copyright © 2005 David A. Hall


Constructor Summary
Unique.UniqueIterable(java.lang.Iterable<? extends T> base)
          Builds a UniqueIterable for the given resource.
Unique.UniqueIterable(java.lang.Iterable<? extends T> base, BinaryFunctor<T,T,java.lang.Boolean> pred)
          Builds a UniqueIterable for the given base iterator that uses the given predicate to compare successive elements.
Unique.UniqueIterable(java.lang.Iterable<? extends T> base, java.util.Comparator<? super T> comp)
          Builds a UniqueIterable for the given base iterator, that uses the given Comparator
 
Method Summary
 java.util.Iterator<T> iterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Unique.UniqueIterable

public Unique.UniqueIterable(java.lang.Iterable<? extends T> base)
Builds a UniqueIterable for the given resource. It will use an EqualTo predicate by default.

Throws:
java.lang.IllegalArgumentException - if the base iterable is null

Unique.UniqueIterable

public Unique.UniqueIterable(java.lang.Iterable<? extends T> base,
                             java.util.Comparator<? super T> comp)
Builds a UniqueIterable for the given base iterator, that uses the given Comparator

Throws:
java.lang.IllegalArgumentException - if either argument is null

Unique.UniqueIterable

public Unique.UniqueIterable(java.lang.Iterable<? extends T> base,
                             BinaryFunctor<T,T,java.lang.Boolean> pred)
Builds a UniqueIterable for the given base iterator that uses the given predicate to compare successive elements. The predicate should return TRUE if its first argument is equal to the second.

Throws:
java.lang.IllegalArgumentException - if the base iterable is null
Method Detail

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>


Copyright © 2002-2006 David A. Hall. All Rights Reserved.