util/IntrusiveHashSet: implement remove_and_dispose_if() with constant_time_size

This commit is contained in:
Max Kellermann 2022-12-01 18:51:55 +01:00 committed by Max Kellermann
parent 7475e971bc
commit 52af03a5a6
1 changed files with 2 additions and 6 deletions

View File

@ -202,19 +202,15 @@ public:
void remove_and_dispose_if(Predicate<const_reference> auto pred,
Disposer<value_type> auto disposer) noexcept {
static_assert(!constant_time_size, "Not yet implemented");
for (auto &bucket : table)
bucket.remove_and_dispose_if(pred, disposer);
counter -= bucket.remove_and_dispose_if(pred, disposer);
}
constexpr void remove_and_dispose_if(const auto &key,
Predicate<const_reference> auto pred,
Disposer<value_type> auto disposer) noexcept {
static_assert(!constant_time_size, "Not yet implemented");
auto &bucket = GetBucket(key);
bucket.remove_and_dispose_if([this, &key, &pred](const auto &item){
counter -= bucket.remove_and_dispose_if([this, &key, &pred](const auto &item){
return equal(key, item) && pred(item);
}, disposer);
}