From 54fb90214f7e9ca43c2f6167c11e172445fb32ab Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 11 Jul 2024 18:22:08 +0300 Subject: [PATCH] Add missing non-template methods for hash table --- libs/util/include/psemek/util/hash_table.hpp | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) 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) {