Added constant index operator to VectorMap.

This commit is contained in:
Patrick 2024-12-18 14:50:01 +01:00
parent 48aeb32ee5
commit 36a9b60e0b

View File

@ -135,6 +135,11 @@ public:
return emplace(key, TValue()).first->second;
}
const TValue& operator[](const TKey& key) const
{
return at(key);
}
[[nodiscard]]
iterator begin() MIJIN_NOEXCEPT { return {keys_.data(), values_.data()}; }
[[nodiscard]]
@ -176,6 +181,11 @@ public:
size_type size() const MIJIN_NOEXCEPT { return keys_.size(); }
[[nodiscard]]
size_type max_size() const MIJIN_NOEXCEPT { return std::min(keys_.max_size(), values_.max_size()); }
void reserve(std::size_t size)
{
keys_.reserve(size);
values_.reserve(size);
}
void clear()
{
@ -241,7 +251,7 @@ public:
{
if (keys_[idx] == key)
{
return iterator(&keys_[idx], &values_[idx]);
return const_iterator(&keys_[idx], &values_[idx]);
}
}
return end();