diff --git a/libs/util/include/psemek/util/hash_table.hpp b/libs/util/include/psemek/util/hash_table.hpp index 389723f6..983f1ac9 100644 --- a/libs/util/include/psemek/util/hash_table.hpp +++ b/libs/util/include/psemek/util/hash_table.hpp @@ -493,6 +493,16 @@ namespace psemek::util return true; } + bool erase(T const & key) + { + if (auto it = find(key); it != end()) + { + erase(it); + return true; + } + return false; + } + template bool erase(Key const & key) { @@ -581,12 +591,22 @@ namespace psemek::util return impl_.insert(std::move(value)); } + iterator find(Key const & key) const + { + return impl_.find(key); + } + template iterator find(Key1 const & key) const { return impl_.find(key); } + bool contains(Key const & key) const + { + return find(key) != end(); + } + template bool contains(Key1 const & key) const { @@ -599,6 +619,16 @@ namespace psemek::util return true; } + bool erase(Key const & key) + { + if (auto it = find(key); it != end()) + { + erase(it); + return true; + } + return false; + } + template bool erase(Key1 const & key) {