llvm.org GIT mirror llvm / 4a6d9cf
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 Chris Lattner 15 years ago
1 changed file(s) with 24 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
111111 std::set TheMapping;
112112
113113 public:
114 EquivalenceClasses() {}
115 EquivalenceClasses(const EquivalenceClasses &RHS) {
116 operator=(RHS);
117 }
118
119 const EquivalenceClasses &operator=(const EquivalenceClasses &RHS) {
120 for (iterator I = RHS.begin(), E = RHS.end(); I != E; ++I)
121 if (I->isLeader())
122 insert(I->getData());
123 else
124 unionSets(I->getData(), *RHS.findLeader(I));
125 return *this;
126 }
114127
115128 //===--------------------------------------------------------------------===//
116129 // Inspection methods
131144 member_iterator member_end() const {
132145 return member_iterator(0);
133146 }
147
148 /// getNumClasses - Return the number of equivalence classes in this set.
149 /// Note that this is a linear time operation.
150 unsigned getNumClasses() const {
151 unsigned NC = 0;
152 for (iterator I = begin(), E = end(); I != E; ++I)
153 if (I->isLeader()) ++NC;
154 return NC;
155 }
156
157
134158
135159 //===--------------------------------------------------------------------===//
136160 // Mutation methods