Class 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$
    Author:
    Haiyang Zheng
    Pt.AcceptedRating:
    Green (hyzheng)
    Pt.ProposedRating:
    Green (hyzheng)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • 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.