Package com.yahoo.collections
Class IntArrayComparator
- java.lang.Object
-
- com.yahoo.collections.IntArrayComparator
-
public class IntArrayComparator extends Object
Utility class which is useful when implementingComparable
and one needs to compare int arrays as instance variables.- Author:
- Einar M R Rosenvinge
-
-
Constructor Summary
Constructors Constructor Description IntArrayComparator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
compare(int[] first, int[] second)
Compare the arguments.
-
-
-
Method Detail
-
compare
public static int compare(int[] first, int[] second)
Compare the arguments. Shorter arrays are always considered smaller than longer arrays. For arrays of equal lengths, the elements are compared one-by-one. Whenever two corresponding elements in the two arrays are non-equal, the method returns. If all elements at corresponding positions in the two arrays are equal, the arrays are considered equal.- Parameters:
first
- an int array to be comparedsecond
- an int array to be compared- Returns:
- 0 if the arguments are equal, -1 if the first argument is smaller, 1 if the second argument is smaller
- Throws:
NullPointerException
- if any of the arguments are null
-
-