diff options
| author | levlam <levlam@telegram.org> | 2024-08-28 10:44:02 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2024-08-28 10:44:02 +0300 |
| commit | d9a2d07e55e64b06a108e4085a29b50c8e7fa990 (patch) | |
| tree | 20044c92ab0e8091d7693efe06ecca0142720849 /tdutils/td/utils/FlatHashMapChunks.h | |
| parent | 11b068547865cf707d727105661b4880b3a88478 (diff) | |
Return whether something was removed by table_remove_if.
Diffstat (limited to 'tdutils/td/utils/FlatHashMapChunks.h')
| -rw-r--r-- | tdutils/td/utils/FlatHashMapChunks.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tdutils/td/utils/FlatHashMapChunks.h b/tdutils/td/utils/FlatHashMapChunks.h index c5fcf4a32..fcf9d89d6 100644 --- a/tdutils/td/utils/FlatHashMapChunks.h +++ b/tdutils/td/utils/FlatHashMapChunks.h @@ -399,13 +399,16 @@ class FlatHashTableChunks { } template <class F> - void remove_if(F &&f) { + bool remove_if(F &&f) { + bool is_removed = false; for (auto it = nodes_.begin(), end = nodes_.end(); it != end; ++it) { if (!it->empty() && f(it->get_public())) { erase_node(it); + is_removed = true; } } try_shrink(); + return is_removed; } private: @@ -568,8 +571,8 @@ template <class KeyT, class HashT = Hash<KeyT>, class EqT = std::equal_to<KeyT>> using FlatHashSetChunks = FlatHashTableChunks<SetNode<KeyT, EqT>, HashT, EqT>; template <class NodeT, class HashT, class EqT, class FuncT> -void table_remove_if(FlatHashTableChunks<NodeT, HashT, EqT> &table, FuncT &&func) { - table.remove_if(func); +bool table_remove_if(FlatHashTableChunks<NodeT, HashT, EqT> &table, FuncT &&func) { + return table.remove_if(func); } } // namespace td |
