Add erase() which returns an iterator pointing to the next element after the
erased one. This makes it possible to erase selected elements while iterating
over the SetVector :
while (I != E) if (test(*I)) I = SetVector.erase(I); else ++I;
Differential D18281
[SetVector] Add erase() method junbuml on Mar 18 2016, 2:14 PM. Authored by
Details Add erase() which returns an iterator pointing to the next element after the while (I != E) if (test(*I)) I = SetVector.erase(I); else ++I;
Diff Detail Event TimelineComment Actions LGTM, but should have a test and should not be committed until you are ready to commit code that is using it.
Comment Actions If reviewers are still okay with the test I added, I will commit this change. Once this change is committed, I will land D17889 which this use this erase() method.
Comment Actions Simplified the unittest as David commented. Please see my inline comment about using find().
Comment Actions And if you for some reason, can't do that (I'd like to understand why not): iterator newIter (vector_.begin()); will work.
Comment Actions Looks good - please commit after removing the extra test & asserts.
Comment Actions Looks like this broke the build: I will revert it. Comment Actions Probably a buggy standard library implementation? Would be good to know In any case, might have to process the iterator in some way to get the Comment Actions
From the Buildbot log above c++4.8 seems to be used which do not have c++11's definition of vector.erase(). Let me get the a non-const iterator as Danny mentioned. Comment Actions Does it have the range definition? |
If the description fits into 1 line you can leave out the "\brief".