From 8b655c40b976998c9dd92957b2c7b19cde6b8bdd Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 21 Sep 2024 16:12:37 -0500 Subject: [PATCH] [ox/std] Add HashMap::values --- deps/ox/src/ox/std/hashmap.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/deps/ox/src/ox/std/hashmap.hpp b/deps/ox/src/ox/std/hashmap.hpp index d38e2c8f..01334352 100644 --- a/deps/ox/src/ox/std/hashmap.hpp +++ b/deps/ox/src/ox/std/hashmap.hpp @@ -64,6 +64,9 @@ class HashMap { [[nodiscard]] constexpr Vector const&keys() const noexcept; + [[nodiscard]] + constexpr Vector values() const noexcept; + constexpr void clear(); private: @@ -198,6 +201,16 @@ constexpr Vector const&HashMap::keys() const noexcept { return m_keys; } +template +constexpr Vector HashMap::values() const noexcept { + Vector out; + out.reserve(m_pairs.size()); + for (auto const&p : m_pairs) { + out.emplace_back(p->value); + } + return out; +} + template constexpr void HashMap::clear() { for (std::size_t i = 0; i < m_pairs.size(); i++) {