ptolemy.actor.util
Class GeneralComparator

java.lang.Object
  extended by ptolemy.actor.util.GeneralComparator
All Implemented Interfaces:
java.util.Comparator

public class GeneralComparator
extends java.lang.Object
implements java.util.Comparator

This class compares two comparable objects, object_1 and object_2, by calling compare(object_1, object_2). A comparable object implements the Comparable interface. This method returns -1, 0, or 1 if object_1 is less than, equal to, or bigger than object_2.

Since:
Ptolemy II 5.2
Version:
$Id: GeneralComparator.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Haiyang Zheng
Accepted Rating:
Green (hyzheng)
Proposed Rating:
Green (hyzheng)

Constructor Summary
GeneralComparator()
           
 
Method Summary
 int compare(java.lang.Object first, java.lang.Object second)
          Return -1, 0, or 1 if the first object is less than, equal to, or bigger than the second object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

GeneralComparator

public GeneralComparator()
Method Detail

compare

public int compare(java.lang.Object first,
                   java.lang.Object second)
Return -1, 0, or 1 if the first object is less than, equal to, or bigger than the second object.

If any of the argument is not a object of Comparable class, a ClassCastException will be thrown.

Specified by:
compare in interface java.util.Comparator
Parameters:
first - The first comparable object.
second - The second comparable object.
Returns:
The comparison result, -1, 0, or 1.