Class ArraysPlume.ObjectArrayComparatorLexical

java.lang.Object
org.plumelib.util.ArraysPlume.ObjectArrayComparatorLexical
All Implemented Interfaces:
Serializable, Comparator<Object[]>
Enclosing class:
ArraysPlume

public static final class ArraysPlume.ObjectArrayComparatorLexical extends Object implements Comparator<Object[]>, 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 equal objects but are not equal according to equals().

Note: if toString returns a nondeterministic value, such as one that depends on the result of hashCode(), then this comparator may yield different orderings from run to run of a program.

See Also:
  • Field Details

  • Constructor Details

    • ObjectArrayComparatorLexical

      @Deprecated public ObjectArrayComparatorLexical()
      Deprecated.
      use it.
      Create a new ObjectArrayComparatorLexical.
  • Method Details

    • compare

      @Pure public int compare(@PolyNull Object[] a1, @PolyNull Object[] a2)
      Compare two arrays lexically (element-by-element).
      Specified by:
      compare in interface Comparator<Object[]>
      Parameters:
      a1 - first array to compare
      a2 - 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