csli.util
Class ComparablePair<Type1 extends Comparable<Type1>,Type2 extends Comparable<Type2>>
java.lang.Object
csli.util.Pair<Type1,Type2>
csli.util.ComparablePair<Type1,Type2>
- All Implemented Interfaces:
- Serializable, Comparable<ComparablePair<Type1,Type2>>
public class ComparablePair<Type1 extends Comparable<Type1>,Type2 extends Comparable<Type2>>
- extends Pair<Type1,Type2>
- implements Comparable<ComparablePair<Type1,Type2>>
A comparable pair. I.e., a pair comparable to another pair of the same
element types.
- Author:
- David Haley
- See Also:
- Serialized Form
ComparablePair
public ComparablePair(Type1 elem1,
Type2 elem2)
compareTo
public int compareTo(ComparablePair<Type1,Type2> rhs)
- Compare this pair to another pair of same type.
Comparison occurs in the following order:
- this.a compared to rhs.a
- if this.a == rhs.a, return this.b compared to rhs.b
In other words, the first element of the pair takes precedence over the
second element during comparison.
- Specified by:
compareTo in interface Comparable<ComparablePair<Type1 extends Comparable<Type1>,Type2 extends Comparable<Type2>>>
- Parameters:
rhs - The pair to compare to.
- Returns:
- -1 if this < rhs; 0 if this == rhs; 1 if this > rhs
- Since:
- 2005-08-08