public interface MultiDimComparable<T>
compareTo(other, i)
used to compare the element of index i from the array.
Another example could be an object representing a person and
containing some information on that person. Then, method
compareTo could compare different informations (age,
height, weight). It can also be used to compare in different ways,
like comparing the birth date including the birth year to know who
is younger or comparing the birth date without the year to know
who will celebrate its next birthday first.
See MultiDimComparator to use these comparisons in
algorithms requiring a regular Java Comparator, e.g., the sort
method in class Arrays.
int dimension()
compareTo can be called for this object. A more formal
definition would be the greatest integer such that
compareTo can be called for
int compareTo(T o, int i)
dimension(), then this method should throw an
IllegalArgumentException.To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.