sparse_set: added free_list(N) for swap_only sets
This commit is contained in:
@@ -240,15 +240,6 @@ protected:
|
||||
/*! @brief Random access iterator type. */
|
||||
using basic_iterator = internal::sparse_set_iterator<packed_container_type>;
|
||||
|
||||
/**
|
||||
* @brief Temporary function to make the transition easier. Don't use me.
|
||||
* @param len The length to use.
|
||||
*/
|
||||
void swap_only_length_temporary_function(const std::size_t len) {
|
||||
ENTT_ASSERT(mode == deletion_policy::swap_only, "Deletion policy mismatch");
|
||||
head = static_cast<underlying_type>(len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases an entity from a sparse set.
|
||||
* @param it An iterator to the element to pop.
|
||||
@@ -518,6 +509,15 @@ public:
|
||||
return static_cast<size_type>(head);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the head of the free list, if possible.
|
||||
* @param len The value to use as the new head of the free list.
|
||||
*/
|
||||
void free_list(const size_type len) noexcept {
|
||||
ENTT_ASSERT((mode == deletion_policy::swap_only) && !(len > packed.size()), "Invalid value");
|
||||
head = static_cast<underlying_type>(len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increases the capacity of a sparse set.
|
||||
*
|
||||
|
||||
@@ -1170,8 +1170,7 @@ public:
|
||||
* @param len The number of elements considered still in use.
|
||||
*/
|
||||
void in_use(const size_type len) noexcept {
|
||||
ENTT_ASSERT(!(len > base_type::size()), "Invalid length");
|
||||
base_type::swap_only_length_temporary_function(len);
|
||||
base_type::free_list(len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user