dense_set: add max_size

This commit is contained in:
Michele Caini
2022-08-03 17:47:54 +02:00
parent abe185c003
commit 57067bc362
2 changed files with 9 additions and 0 deletions

View File

@@ -469,6 +469,14 @@ public:
return packed.first().size();
}
/**
* @brief Returns the maximum possible number of elements.
* @return Maximum possible number of elements.
*/
[[nodiscard]] size_type max_size() const noexcept {
return packed.first().max_size();
}
/*! @brief Clears the container. */
void clear() noexcept {
sparse.first().clear();

View File

@@ -32,6 +32,7 @@ TEST(DenseSet, Functionalities) {
ASSERT_EQ(set.size(), 0u);
ASSERT_EQ(set.load_factor(), 0.f);
ASSERT_EQ(set.max_load_factor(), .875f);
ASSERT_EQ(set.max_size(), (std::vector<std::pair<std::size_t, std::size_t>>{}.max_size()));
set.max_load_factor(.9f);