[ox/std] Add HashMap::values

This commit is contained in:
Gary Talent 2024-09-21 16:12:37 -05:00
parent 92d85d1145
commit 8b655c40b9

View File

@ -64,6 +64,9 @@ class HashMap {
[[nodiscard]] [[nodiscard]]
constexpr Vector<K> const&keys() const noexcept; constexpr Vector<K> const&keys() const noexcept;
[[nodiscard]]
constexpr Vector<T> values() const noexcept;
constexpr void clear(); constexpr void clear();
private: private:
@ -198,6 +201,16 @@ constexpr Vector<K> const&HashMap<K, T>::keys() const noexcept {
return m_keys; return m_keys;
} }
template<typename K, typename T>
constexpr Vector<T> HashMap<K, T>::values() const noexcept {
Vector<T> out;
out.reserve(m_pairs.size());
for (auto const&p : m_pairs) {
out.emplace_back(p->value);
}
return out;
}
template<typename K, typename T> template<typename K, typename T>
constexpr void HashMap<K, T>::clear() { constexpr void HashMap<K, T>::clear() {
for (std::size_t i = 0; i < m_pairs.size(); i++) { for (std::size_t i = 0; i < m_pairs.size(); i++) {