util/IntrusiveList: remove_and_dispose_if() returns the number of removed items
This commit is contained in:
parent
c65b1fee8d
commit
7475e971bc
@ -296,8 +296,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_and_dispose_if(Predicate<const_reference> auto pred,
|
/**
|
||||||
Disposer<value_type> auto dispose) noexcept {
|
* @return the number of removed items
|
||||||
|
*/
|
||||||
|
std::size_t remove_and_dispose_if(Predicate<const_reference> auto pred,
|
||||||
|
Disposer<value_type> auto dispose) noexcept {
|
||||||
|
std::size_t result = 0;
|
||||||
|
|
||||||
auto *n = head.next;
|
auto *n = head.next;
|
||||||
|
|
||||||
while (n != &head) {
|
while (n != &head) {
|
||||||
@ -308,8 +313,11 @@ public:
|
|||||||
ToHook(*i).unlink();
|
ToHook(*i).unlink();
|
||||||
--counter;
|
--counter;
|
||||||
dispose(i);
|
dispose(i);
|
||||||
|
++result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reference front() const noexcept {
|
const_reference front() const noexcept {
|
||||||
|
Loading…
Reference in New Issue
Block a user