Pair class
class Pair implements Comparable { DynamicTreeNode proxyA; DynamicTreeNode proxyB; /** * Constructs a new pair. */ Pair() : proxyA = null, proxyB = null { } /** * Compares this pair to the other pair. Returns a negative number if this * pair is less, 0 if the pairs are equal, and a positive number if this pair * is greater. Compared first on which proxyA is less and, in the case of a * tie, on which proxyB is less. */ int compareTo(Pair pair2) { assert(proxyA != null && pair2.proxyA != null); if (this.proxyA.key < pair2.proxyA.key) return -1; if (this.proxyA.key == pair2.proxyA.key) { return (proxyB.key < pair2.proxyB.key) ? -1 : (proxyB.key == pair2.proxyB.key) ? 0 : 1; } return 1; } }
Implements
Constructors
new Pair() #
Constructs a new pair.
Pair() : proxyA = null, proxyB = null { }
Properties
DynamicTreeNode proxyA #
DynamicTreeNode proxyA
DynamicTreeNode proxyB #
DynamicTreeNode proxyB
Methods
int compareTo(Pair pair2) #
Compares this pair to the other pair. Returns a negative number if this pair is less, 0 if the pairs are equal, and a positive number if this pair is greater. Compared first on which proxyA is less and, in the case of a tie, on which proxyB is less.
int compareTo(Pair pair2) { assert(proxyA != null && pair2.proxyA != null); if (this.proxyA.key < pair2.proxyA.key) return -1; if (this.proxyA.key == pair2.proxyA.key) { return (proxyB.key < pair2.proxyB.key) ? -1 : (proxyB.key == pair2.proxyB.key) ? 0 : 1; } return 1; }