From 99885c4cbcbb5545708104825cb56d67e20c4517 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 22 Mar 2023 15:13:30 +0100 Subject: [PATCH] util/IntrusiveHashSet: add method remove_and_dispose() --- src/util/IntrusiveHashSet.hxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/util/IntrusiveHashSet.hxx b/src/util/IntrusiveHashSet.hxx index 7c00ac687..7d7ab6285 100644 --- a/src/util/IntrusiveHashSet.hxx +++ b/src/util/IntrusiveHashSet.hxx @@ -188,6 +188,17 @@ public: counter -= bucket.remove_and_dispose_if(pred, disposer); } + /** + * Remove and dispose all items with the specified key. + */ + constexpr void remove_and_dispose(const auto &key, + Disposer auto disposer) noexcept { + auto &bucket = GetBucket(key); + counter -= bucket.remove_and_dispose_if([this, &key](const auto &item){ + return equal(key, item); + }, disposer); + } + constexpr void remove_and_dispose_if(const auto &key, Predicate auto pred, Disposer auto disposer) noexcept {