@@ -175,6 +175,11 @@ class EquivalenceClasses {
175175 // Only leaders provide anything to iterate over.
176176 return member_iterator (I->isLeader () ? &*I : nullptr );
177177 }
178+ member_iterator member_begin (const ECValue &ECV) const {
179+ // Only leaders provide anything to iterate over.
180+ return member_iterator (ECV.getLeader ());
181+ }
182+
178183 member_iterator member_end () const {
179184 return member_iterator (nullptr );
180185 }
@@ -216,26 +221,28 @@ class EquivalenceClasses {
216221
217222 // / insert - Insert a new value into the union/find set, ignoring the request
218223 // / if the value already exists.
219- iterator insert (const ElemTy &Data) {
220- return TheMapping.insert (ECValue (Data)).first ;
224+ const ECValue & insert (const ElemTy &Data) {
225+ return * TheMapping.insert (ECValue (Data)).first ;
221226 }
222227
223228 // / findLeader - Given a value in the set, return a member iterator for the
224229 // / equivalence class it is in. This does the path-compression part that
225230 // / makes union-find "union findy". This returns an end iterator if the value
226231 // / is not in the equivalence class.
227- member_iterator findLeader (iterator I) const {
228- if (I == TheMapping.end ()) return member_end ();
229- return member_iterator (I->getLeader ());
230- }
231232 member_iterator findLeader (const ElemTy &V) const {
232- return findLeader (TheMapping.find (V));
233+ auto I = TheMapping.find (V);
234+ if (I == TheMapping.end ())
235+ return member_iterator (nullptr );
236+ return findLeader (*I);
237+ }
238+ member_iterator findLeader (const ECValue &ECV) const {
239+ return member_iterator (ECV.getLeader ());
233240 }
234241
235242 // / union - Merge the two equivalence sets for the specified values, inserting
236243 // / them if they do not already exist in the equivalence set.
237244 member_iterator unionSets (const ElemTy &V1, const ElemTy &V2) {
238- iterator V1I = insert (V1), V2I = insert (V2);
245+ const ECValue & V1I = insert (V1), & V2I = insert (V2);
239246 return unionSets (findLeader (V1I), findLeader (V2I));
240247 }
241248 member_iterator unionSets (member_iterator L1, member_iterator L2) {
0 commit comments