summaryrefslogtreecommitdiff
path: root/asl/hash_map.hpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2025-01-18 23:31:54 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2025-01-18 23:31:54 +0100
commit9487f0e564bbb5163ad33860d82f2be16b7ab562 (patch)
treec7e42862b82496b08a3cd6c7d4621d080bcc8bbe /asl/hash_map.hpp
parent74082720c42c5d6b06b71cefbad4b794ff1b8c3c (diff)
Add contiguous iterators
Diffstat (limited to 'asl/hash_map.hpp')
-rw-r--r--asl/hash_map.hpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/asl/hash_map.hpp b/asl/hash_map.hpp
index 300ffdb..93f93e7 100644
--- a/asl/hash_map.hpp
+++ b/asl/hash_map.hpp
@@ -147,9 +147,23 @@ public:
// NOLINTEND(*-pointer-arithmetic)
}
+ // @Todo(C++23) Deducing this
template<typename U>
requires key_hasher<KeyHasher, U> && key_comparator<KeyComparator, K, U>
- V* get(const U& value) const
+ const V* get(const U& value) const
+ {
+ isize_t index = Base::find_slot_lookup(value);
+ if (index >= 0)
+ {
+ // NOLINTNEXTLINE(*-pointer-arithmetic)
+ return &Base::m_values[index].as_init_unsafe().value;
+ }
+ return nullptr;
+ }
+
+ template<typename U>
+ requires key_hasher<KeyHasher, U> && key_comparator<KeyComparator, K, U>
+ V* get(const U& value)
{
isize_t index = Base::find_slot_lookup(value);
if (index >= 0)