[ox/std] Add HashMap::values
This commit is contained in:
parent
92d85d1145
commit
8b655c40b9
13
deps/ox/src/ox/std/hashmap.hpp
vendored
13
deps/ox/src/ox/std/hashmap.hpp
vendored
@ -64,6 +64,9 @@ class HashMap {
|
||||
[[nodiscard]]
|
||||
constexpr Vector<K> const&keys() const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Vector<T> values() const noexcept;
|
||||
|
||||
constexpr void clear();
|
||||
|
||||
private:
|
||||
@ -198,6 +201,16 @@ constexpr Vector<K> const&HashMap<K, T>::keys() const noexcept {
|
||||
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>
|
||||
constexpr void HashMap<K, T>::clear() {
|
||||
for (std::size_t i = 0; i < m_pairs.size(); i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user