Make util::hash_table search heterogeneous & add hash_table::contains

This commit is contained in:
Nikita Lisitsa 2023-08-24 17:32:57 +03:00
parent 183644d46f
commit 809a0ec212

View file

@ -344,9 +344,16 @@ namespace psemek::util
return {result.first.as_const(), result.second}; return {result.first.as_const(), result.second};
} }
iterator find(T const & value) const template <typename Key>
iterator find(Key const & key) const
{ {
return impl_.find(value).as_const(); return impl_.find(key).as_const();
}
template <typename Key>
bool contains(Key const & key) const
{
return find(key) != end();
} }
iterator begin() const iterator begin() const
@ -392,11 +399,18 @@ namespace psemek::util
return impl_.insert(std::move(value)); return impl_.insert(std::move(value));
} }
iterator find(Key const & key) const template <typename Key1>
iterator find(Key1 const & key) const
{ {
return impl_.find(key); return impl_.find(key);
} }
template <typename Key1>
bool contains(Key1 const & key) const
{
return find(key) != end();
}
iterator begin() const iterator begin() const
{ {
return impl_.begin(); return impl_.begin();