Package org.plumelib.util
Class ArraysPlume.DoubleArrayComparatorLexical
java.lang.Object
org.plumelib.util.ArraysPlume.DoubleArrayComparatorLexical
- All Implemented Interfaces:
Serializable
,Comparator<double[]>
- Enclosing class:
- ArraysPlume
public static final class ArraysPlume.DoubleArrayComparatorLexical
extends Object
implements Comparator<double[]>, Serializable
Compare two arrays lexically (element-by-element). If all shared elements are the same, but the
lengths differ, then the shorter array is considered less.
Note: this comparator imposes orderings that are inconsistent with Object.equals(java.lang.Object)
.
That is, it may return 0 if the arrays contain identical numbers but are not equal according to
equals()
(which tests reference equality).
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ArraysPlume.DoubleArrayComparatorLexical
The canonical DoubleArrayComparatorLexical. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
compare
(double[] a1, double[] a2) Compare two arrays lexically (element-by-element).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
-
Field Details
-
it
The canonical DoubleArrayComparatorLexical.
-
-
Constructor Details
-
DoubleArrayComparatorLexical
Deprecated.useit
.Create a new DoubleArrayComparatorLexical.
-
-
Method Details
-
compare
@Pure public int compare(double[] a1, double[] a2) Compare two arrays lexically (element-by-element).- Specified by:
compare
in interfaceComparator<double[]>
- Parameters:
a1
- first array to comparea2
- second array to compare- Returns:
- a negative integer, zero, or a positive integer, depending on whether the first argument is less than, equal to, or greater than the second argument
-
it
.