com.silentq.sort
Class Compare

java.lang.Object
  |
  +--com.silentq.sort.Compare

public class Compare
extends java.lang.Object

The comparison class - evaluates "less than". This class does all the comparisons for the sorting algorithms. All of them can be reduced to one comparison: less than. This class implements less than for all appropriate Java types. It also contains a utility method - swap, which swaps two values in a Vector.


Constructor Summary
Compare()
           
 
Method Summary
static boolean lessThan(java.lang.Character less, java.lang.Character more)
          The lessThan method for Characters.
static boolean lessThan(java.util.Date less, java.util.Date more)
          The lessThan method for Dates.
static boolean lessThan(java.lang.Number less, java.lang.Number more)
          The lessThan method for Numbers.
static boolean lessThan(java.lang.Object less, java.lang.Object more)
          This is the main method.
static boolean lessThan(java.lang.String less, java.lang.String more)
          The lessThan method for Strings.
static void swap(java.util.Vector values, int index1, int index2)
          This is a utility method that swaps two values in a Vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compare

public Compare()
Method Detail

lessThan

public static boolean lessThan(java.lang.Object less,
                               java.lang.Object more)
This is the main method. It checks the Object Class of the items (which must be the same Class), and calls the specific method to test that Class.
Parameters:
less - The less-than test item.
more - The more-than test item.
Returns:
True if less is less than more.

lessThan

public static boolean lessThan(java.lang.Number less,
                               java.lang.Number more)
The lessThan method for Numbers.
Parameters:
less - The less-than test item.
more - The more-than test item.
Returns:
True if less is less than more.

lessThan

public static boolean lessThan(java.lang.Character less,
                               java.lang.Character more)
The lessThan method for Characters.
Parameters:
less - The less-than test item.
more - The more-than test item.
Returns:
True if less is before more.

lessThan

public static boolean lessThan(java.util.Date less,
                               java.util.Date more)
The lessThan method for Dates.
Parameters:
less - The less-than test item.
more - The more-than test item.
Returns:
True if less is before more.

lessThan

public static boolean lessThan(java.lang.String less,
                               java.lang.String more)
The lessThan method for Strings.
Parameters:
less - The less-than test item.
more - The more-than test item.
Returns:
True if less is alphabetically before more.

swap

public static void swap(java.util.Vector values,
                        int index1,
                        int index2)
This is a utility method that swaps two values in a Vector.
Parameters:
values - The Vector.
index1 - The index of the first value.
index2 - The index of the second value.