|
SSJ V. labo. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MultiDimComparable<T>
This interface represents an object which can be compared in many
dimensions or in many ways. This is very flexible. Objects that
are compared may really have a multidimensional behavior, or they
may not.
For example, an object that contains an array could implement this
interface with method 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.
Method Summary | |
---|---|
int |
compareTo(T o,
int i)
Compares objects of type T in the i-th dimension. |
int |
dimension()
This method returns the number of dimensions for which the method compareTo can be called for this object. |
Method Detail |
---|
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
.
|
SSJ V. labo. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |