mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-06 09:44:39 +00:00
implement a proper copy ctor, operator= and add a helper method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20690 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
efd02c750f
commit
4a6d9cf122
@ -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…
x
Reference in New Issue
Block a user