From 9487f0e564bbb5163ad33860d82f2be16b7ab562 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Sat, 18 Jan 2025 23:31:54 +0100 Subject: Add contiguous iterators --- asl/hash_map.hpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'asl/hash_map.hpp') 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 requires key_hasher && key_comparator - 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 + requires key_hasher && key_comparator + V* get(const U& value) { isize_t index = Base::find_slot_lookup(value); if (index >= 0) -- cgit