diff --git a/AK/HashMap.h b/AK/HashMap.h index b2fa38125e..dc8f74ac33 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -95,7 +95,23 @@ public: void ensure_capacity(size_t capacity) { m_table.ensure_capacity(capacity); } - Optional::PeekType> get(const K& key) const + Optional::PeekType> get(const K& key) const requires(!IsPointer::PeekType>) + { + auto it = find(key); + if (it == end()) + return {}; + return (*it).value; + } + + Optional::ConstPeekType> get(const K& key) const requires(IsPointer::PeekType>) + { + auto it = find(key); + if (it == end()) + return {}; + return (*it).value; + } + + Optional::PeekType> get(const K& key) requires(!IsConst::PeekType>) { auto it = find(key); if (it == end())