mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-08 12:21:04 +00:00
implement a proper copy ctor, operator= and add a helper method.
llvm-svn: 20690
This commit is contained in:
parent
f53c9e2578
commit
e4d74b8d85
@ -112,6 +112,19 @@ class EquivalenceClasses {
|
||||
std::set<ECValue> TheMapping;
|
||||
|
||||
public:
|
||||
EquivalenceClasses() {}
|
||||
EquivalenceClasses(const EquivalenceClasses &RHS) {
|
||||
operator=(RHS);
|
||||
}
|
||||
|
||||
const EquivalenceClasses &operator=(const EquivalenceClasses &RHS) {
|
||||
for (iterator I = RHS.begin(), E = RHS.end(); I != E; ++I)
|
||||
if (I->isLeader())
|
||||
insert(I->getData());
|
||||
else
|
||||
unionSets(I->getData(), *RHS.findLeader(I));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Inspection methods
|
||||
@ -133,6 +146,17 @@ public:
|
||||
return member_iterator(0);
|
||||
}
|
||||
|
||||
/// getNumClasses - Return the number of equivalence classes in this set.
|
||||
/// Note that this is a linear time operation.
|
||||
unsigned getNumClasses() const {
|
||||
unsigned NC = 0;
|
||||
for (iterator I = begin(), E = end(); I != E; ++I)
|
||||
if (I->isLeader()) ++NC;
|
||||
return NC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Mutation methods
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user