NumClasses = 0;
}
- /// join - Join the equivalence classes of a and b. After joining classes,
- /// findLeader(a) == findLeader(b).
- /// This requires an uncompressed map.
- void join(unsigned a, unsigned b);
+ /// Join the equivalence classes of a and b. After joining classes,
+ /// findLeader(a) == findLeader(b). This requires an uncompressed map.
+ /// Returns the new leader.
+ unsigned join(unsigned a, unsigned b);
/// findLeader - Compute the leader of a's equivalence class. This is the
/// smallest member of the class.
EC.push_back(EC.size());
}
-void IntEqClasses::join(unsigned a, unsigned b) {
+unsigned IntEqClasses::join(unsigned a, unsigned b) {
assert(NumClasses == 0 && "join() called after compress().");
unsigned eca = EC[a];
unsigned ecb = EC[b];
EC[b] = eca, b = ecb, ecb = EC[b];
else
EC[a] = ecb, a = eca, eca = EC[a];
+
+ return eca;
}
unsigned IntEqClasses::findLeader(unsigned a) const {