diff options
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-dictionary.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/core/slang-dictionary.h b/source/core/slang-dictionary.h index 639978a08..d35255a8c 100644 --- a/source/core/slang-dictionary.h +++ b/source/core/slang-dictionary.h @@ -148,6 +148,25 @@ public: // Erases the value at the specified key if it exists void remove(const TKey& key) { map.erase(key); } + // Removes all values satifying the predicate: + // bool predicate(pair<Key, Value>) + template<typename Predicate> + void removeIf(Predicate&& predicate) + { + auto it = begin(); + while (it != end()) + { + if (predicate(*it)) + { + it = map.erase(it); + } + else + { + ++it; + } + } + } + // Reserves enough space for the specified number of values void reserve(Index size) { map.reserve(std::size_t(size)); }; |
