org.finetracker
Class IteratorComparator<T extends java.lang.Comparable<T>,E extends java.lang.Iterable<T>>

java.lang.Object
  extended by org.finetracker.IteratorComparator<T,E>
Type Parameters:
T - a class implementing Comparable, which can be just about anything
E - an Iterable, which are lists, queues, etc. Collections and sets are also possible, but since the order of a Set is not guaranteed, the outcome of a comparison using this class isn't either.
All Implemented Interfaces:
java.util.Comparator<E>

public class IteratorComparator<T extends java.lang.Comparable<T>,E extends java.lang.Iterable<T>>
extends java.lang.Object
implements java.util.Comparator<E>

Generic class which compares two Iterable objects, which may be lists, sets, collections, arrays, etc.

Author:
Frank Kusters

Constructor Summary
IteratorComparator()
           
 
Method Summary
 int compare(E o1, E o2)
          Compares two Iterable objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

IteratorComparator

public IteratorComparator()
Method Detail

compare

public int compare(E o1,
                   E o2)
Compares two Iterable objects. It is considered 'better' if, in order of importance:

Specified by:
compare in interface java.util.Comparator<E extends java.lang.Iterable<T>>
Parameters:
o1 - the first Iterable
o2 - the second Iterable
Returns:
a negative number if o1 is 'better' than o2, 0 if they are equal, and a positive number if o2 is 'better' than o1.
See Also:
Comparator.compare(java.lang.Object, java.lang.Object)