diff --git a/src/util/IntrusiveList.hxx b/src/util/IntrusiveList.hxx index 183e98c93..7d0a5f310 100644 --- a/src/util/IntrusiveList.hxx +++ b/src/util/IntrusiveList.hxx @@ -296,8 +296,13 @@ public: } } - void remove_and_dispose_if(Predicate auto pred, - Disposer auto dispose) noexcept { + /** + * @return the number of removed items + */ + std::size_t remove_and_dispose_if(Predicate auto pred, + Disposer auto dispose) noexcept { + std::size_t result = 0; + auto *n = head.next; while (n != &head) { @@ -308,8 +313,11 @@ public: ToHook(*i).unlink(); --counter; dispose(i); + ++result; } } + + return result; } const_reference front() const noexcept {