Add hash_table::reserve

This commit is contained in:
Nikita Lisitsa 2025-09-16 20:44:42 +03:00
parent 7300679f56
commit 7c5062e081

View file

@ -269,6 +269,11 @@ namespace psemek::util
return storage_.capacity; return storage_.capacity;
} }
void reserve(std::size_t capacity)
{
ensure_capacity_for(capacity);
}
private: private:
hash_table_storage<T> storage_; hash_table_storage<T> storage_;
std::size_t size_ = 0; std::size_t size_ = 0;
@ -516,6 +521,11 @@ namespace psemek::util
return impl_.size(); return impl_.size();
} }
void reserve(std::size_t capacity)
{
impl_.reserve(capacity);
}
private: private:
detail::hash_table_impl<T, Hash, Equal, detail::id_key_projector> impl_; detail::hash_table_impl<T, Hash, Equal, detail::id_key_projector> impl_;
}; };
@ -691,6 +701,11 @@ namespace psemek::util
return impl_.size() == 0; return impl_.size() == 0;
} }
void reserve(std::size_t capacity)
{
impl_.reserve(capacity);
}
private: private:
detail::hash_table_impl<std::pair<Key const, Value>, KeyHash, KeyEqual, detail::pair_key_projector> impl_; detail::hash_table_impl<std::pair<Key const, Value>, KeyHash, KeyEqual, detail::pair_key_projector> impl_;
}; };