compareTo
public int compareTo(Pair<T1,T2> o)
Description copied from class: Pair
Compares this Pair to another object.
If the object is a Pair, this function will work providing
the elements of the Pair are themselves comparable.
It will then return a value based on the pair of objects, where
p > q iff p.first() > q.first() ||
(p.first().equals(q.first()) && p.second() > q.second()).
If the other object is not a Pair, it throws a
ClassCastException.
- Specified by:
compareTo in interface java.lang.Comparable<Pair<T1,T2>>
- Overrides:
compareTo in class Pair<T1,T2>
- Parameters:
o - the Object to be compared.
- Returns:
- the value
0 if the argument is a
Pair equal to this Pair; a value less than
0 if the argument is a Pair
greater than this Pair; and a value
greater than 0 if the argument is a
Pair less than this Pair.
- See Also:
Comparable