net.sf.jga.algorithms
Class Unique

java.lang.Object
  extended by net.sf.jga.algorithms.Unique

public class Unique
extends java.lang.Object

Algorithms that eliminate successive duplicate entries from a collection, iteration, or iterable resource.

Copyright © 2006 David A. Hall


Nested Class Summary
static class Unique.UniqueIterable<T>
          Produces iterators that will not return the same element twice in succession.
static class Unique.UniqueIterator<T>
          Iterator that will not return the same element twice in succession.
 
Constructor Summary
Unique()
           
 
Method Summary
static
<T> java.lang.Iterable<T>
unique(java.lang.Iterable<? extends T> i)
          Returns the contents of the input, skipping duplicate entries.
static
<T> java.lang.Iterable<T>
unique(java.lang.Iterable<? extends T> i, BinaryFunctor<T,T,java.lang.Boolean> eq)
           
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
unique(java.lang.Iterable<? extends T> lin, BinaryFunctor<T,T,java.lang.Boolean> eq, TCollection cout)
          Appends the contents of the input (skipping duplicate entries as determined by the given predicate) to the output.
static
<T> java.lang.Iterable<T>
unique(java.lang.Iterable<? extends T> i, java.util.Comparator<? super T> comp)
           
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
unique(java.lang.Iterable<? extends T> lin, java.util.Comparator<? super T> comp, TCollection cout)
          Appends the contents of the input (skipping duplicate entries as determined by the given comparator) to the output.
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
unique(java.lang.Iterable<? extends T> lin, TCollection cout)
          Appends the contents of the input (skipping duplicate entries) to the output.
static
<T> java.util.Iterator<T>
unique(java.util.Iterator<? extends T> iterator)
          Returns the contents of the iterator, skipping duplicate entries.
static
<T> java.util.Iterator<T>
unique(java.util.Iterator<? extends T> iterator, BinaryFunctor<T,T,java.lang.Boolean> eq)
          Returns the contents of the iterator, skipping duplicate entries as determined by the given predicate.
static
<T> java.util.Iterator<T>
unique(java.util.Iterator<? extends T> iterator, java.util.Comparator<? super T> comp)
          Returns the contents of the iterator, skipping duplicate entries as determined by the given comparator.
static
<T> java.lang.Iterable<T>
unique(T[] ts)
          Returns the elements of the array, skipping duplicate entries.
static
<T> java.lang.Iterable<T>
unique(T[] ts, BinaryFunctor<T,T,java.lang.Boolean> eq)
          Returns the elements of the array, skipping duplicate entries as determined by the given predicate.
static
<T> java.lang.Iterable<T>
unique(T[] ts, java.util.Comparator<? super T> comp)
          Returns the elements of the array, skipping duplicate entries as determined by the given comparator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Unique

public Unique()
Method Detail

unique

public static <T> java.lang.Iterable<T> unique(T[] ts)
Returns the elements of the array, skipping duplicate entries. This version uses T.equals() to test for equality.


unique

public static <T> java.lang.Iterable<T> unique(T[] ts,
                                               java.util.Comparator<? super T> comp)
Returns the elements of the array, skipping duplicate entries as determined by the given comparator.


unique

public static <T> java.lang.Iterable<T> unique(T[] ts,
                                               BinaryFunctor<T,T,java.lang.Boolean> eq)
Returns the elements of the array, skipping duplicate entries as determined by the given predicate. The predicate should return true when the adjacent items are the same.


unique

public static <T> java.lang.Iterable<T> unique(java.lang.Iterable<? extends T> i)
Returns the contents of the input, skipping duplicate entries. This version uses T.equals() to test for equality.


unique

public static <T> java.lang.Iterable<T> unique(java.lang.Iterable<? extends T> i,
                                               java.util.Comparator<? super T> comp)

unique

public static <T> java.lang.Iterable<T> unique(java.lang.Iterable<? extends T> i,
                                               BinaryFunctor<T,T,java.lang.Boolean> eq)

unique

public static <T> java.util.Iterator<T> unique(java.util.Iterator<? extends T> iterator)
Returns the contents of the iterator, skipping duplicate entries. This version uses T.equals() to test for equality.


unique

public static <T> java.util.Iterator<T> unique(java.util.Iterator<? extends T> iterator,
                                               java.util.Comparator<? super T> comp)
Returns the contents of the iterator, skipping duplicate entries as determined by the given comparator.


unique

public static <T> java.util.Iterator<T> unique(java.util.Iterator<? extends T> iterator,
                                               BinaryFunctor<T,T,java.lang.Boolean> eq)
Returns the contents of the iterator, skipping duplicate entries as determined by the given predicate. The predicate should return true when the adjacent items are the same.


unique

public static <T,TCollection extends java.util.Collection<? super T>> TCollection unique(java.lang.Iterable<? extends T> lin,
                                                                                         TCollection cout)
Appends the contents of the input (skipping duplicate entries) to the output. This version uses T.equals() to test for equality.


unique

public static <T,TCollection extends java.util.Collection<? super T>> TCollection unique(java.lang.Iterable<? extends T> lin,
                                                                                         java.util.Comparator<? super T> comp,
                                                                                         TCollection cout)
Appends the contents of the input (skipping duplicate entries as determined by the given comparator) to the output.


unique

public static <T,TCollection extends java.util.Collection<? super T>> TCollection unique(java.lang.Iterable<? extends T> lin,
                                                                                         BinaryFunctor<T,T,java.lang.Boolean> eq,
                                                                                         TCollection cout)
Appends the contents of the input (skipping duplicate entries as determined by the given predicate) to the output.



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