diff options
| author | levlam <levlam@telegram.org> | 2025-06-23 01:37:48 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2025-06-23 01:37:48 +0300 |
| commit | 3c8bbc53c34bd0ef8ffdc406c9c8d8b71db73465 (patch) | |
| tree | 0fe1c837a659716f46da7f192b14ef42e647c966 /tdutils/td/utils/WaitFreeHashMap.h | |
| parent | 571e9c7be11a56e091e51322718122c26a111cb7 (diff) | |
Add WaitFreeHashMap::remove_if.
Diffstat (limited to 'tdutils/td/utils/WaitFreeHashMap.h')
| -rw-r--r-- | tdutils/td/utils/WaitFreeHashMap.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tdutils/td/utils/WaitFreeHashMap.h b/tdutils/td/utils/WaitFreeHashMap.h index 592ac96d9..956a1a865 100644 --- a/tdutils/td/utils/WaitFreeHashMap.h +++ b/tdutils/td/utils/WaitFreeHashMap.h @@ -161,6 +161,21 @@ class WaitFreeHashMap { } } + template <class F> + bool remove_if(const F &f) { + if (wait_free_storage_ == nullptr) { + return default_map_.remove_if(f); + } + + bool is_removed = false; + for (auto &it : wait_free_storage_->maps_) { + if (it.remove_if(f)) { + is_removed = true; + } + } + return is_removed; + } + size_t calc_size() const { if (wait_free_storage_ == nullptr) { return default_map_.size(); |
