From 809a0ec212809c046772eb122f4ebf6560bbaf2e Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 24 Aug 2023 17:32:57 +0300 Subject: [PATCH] Make util::hash_table search heterogeneous & add hash_table::contains --- libs/util/include/psemek/util/hash_table.hpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libs/util/include/psemek/util/hash_table.hpp b/libs/util/include/psemek/util/hash_table.hpp index ba9f9937..bebfc781 100644 --- a/libs/util/include/psemek/util/hash_table.hpp +++ b/libs/util/include/psemek/util/hash_table.hpp @@ -344,9 +344,16 @@ namespace psemek::util return {result.first.as_const(), result.second}; } - iterator find(T const & value) const + template + iterator find(Key const & key) const { - return impl_.find(value).as_const(); + return impl_.find(key).as_const(); + } + + template + bool contains(Key const & key) const + { + return find(key) != end(); } iterator begin() const @@ -392,11 +399,18 @@ namespace psemek::util return impl_.insert(std::move(value)); } - iterator find(Key const & key) const + template + iterator find(Key1 const & key) const { return impl_.find(key); } + template + bool contains(Key1 const & key) const + { + return find(key) != end(); + } + iterator begin() const { return impl_.begin();