planet.symphony
Interface Comparer

All Known Implementing Classes:
IdComparer

public interface Comparer

Comparer interface imposes a total ordering on some collection of objects. The data structure calls compare method and gets the order of the elements on the collection. The ordering imposed by Comparer c must be consistent and implies an specific definition of a comparer for each object's type.

Author:
Marc Sanchez (marc.sanchez@estudiants.urv.es)

Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          A comparison function, which imposes a total ordering on some collection of objects.
 

Method Detail

compare

int compare(java.lang.Object o1,
            java.lang.Object o2)
A comparison function, which imposes a total ordering on some collection of objects. Comparer can be passed to a sort method to allow precise control over the sort order. Comparer can also be used to control the order of certain data structures. The ordering imposed by a Comparer c on a set of elements S is said to be consistent with equals if and only if (compare((Object)e1, (Object)e2)==0) has the same boolean value as e1.equals((Object)e2) for every e1 and e2 in S.

Parameters:
o1 - The first object to be compared.
o2 - The second object to be compared.
Returns:
A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
Throws:
java.lang.ClassCastException - - if the arguments' types prevent them from being compared by this Comparer.