Package adams.core
Class CompareUtils
- java.lang.Object
-
- adams.core.CompareUtils
-
public class CompareUtils extends Object
Utility class for comparisons.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description CompareUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
compare(int[] a1, int[] a2)
Compares two integer arrays.static int
compare(Comparable o1, Comparable o2)
Compares two comparable objects.static int
compare(Map m1, Map m2)
Compares two maps.
-
-
-
Method Detail
-
compare
public static int compare(Comparable o1, Comparable o2)
Compares two comparable objects. Takes care of null objects. Returns -1, 0 or +1, if o1 less than, equal to or greater than o2. Returns 0 if both objects null, -1 if o1 null but not o2 and +1 if o1 not null but o2.- Parameters:
o1
- the first objecto2
- the second object- Returns:
- the comparison result
-
compare
public static int compare(int[] a1, int[] a2)
Compares two integer arrays.- Parameters:
a1
- the first arraya2
- the second array- Returns:
- -1, 0, +1 if a1 is smaller than, equal to, or larger than a2
-
compare
public static int compare(Map m1, Map m2)
Compares two maps. Both, keys and values must beComparable
.- Parameters:
m1
- the first mapm2
- the second map- Returns:
- the comparison result
-
-