IdList::RemoveTagged switch to std::remove_if from iteration. NFC.
This commit is contained in:
parent
3ea077b70f
commit
0bb6a348e3
26
src/dsc.h
26
src/dsc.h
@ -474,24 +474,22 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RemoveTagged() {
|
void RemoveTagged() {
|
||||||
int src, dest;
|
auto newEnd = std::remove_if(this->begin(), this->end(), [](T &t) {
|
||||||
dest = 0;
|
if(t.tag) {
|
||||||
for(src = 0; src < n; src++) {
|
t.Clear();
|
||||||
if(elem[src].tag) {
|
return true;
|
||||||
// this item should be deleted
|
|
||||||
elem[src].Clear();
|
|
||||||
} else {
|
|
||||||
if(src != dest) {
|
|
||||||
elem[dest] = elem[src];
|
|
||||||
}
|
}
|
||||||
dest++;
|
return false;
|
||||||
|
});
|
||||||
|
if(newEnd != this->end()) {
|
||||||
|
while (newEnd != this->end()) {
|
||||||
|
newEnd->~T();
|
||||||
|
++newEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i = dest; i < n; i++)
|
n = newEnd - begin();
|
||||||
elem[i].~T();
|
|
||||||
n = dest;
|
|
||||||
// and elemsAllocated is untouched, because we didn't resize
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveById(H h) {
|
void RemoveById(H h) {
|
||||||
ClearTags();
|
ClearTags();
|
||||||
FindById(h)->tag = 1;
|
FindById(h)->tag = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user