|
@@ -1025,7 +1025,7 @@ public:
|
|
|
*/
|
|
*/
|
|
|
template<typename Compare, typename Sort = std_sort, typename... Args>
|
|
template<typename Compare, typename Sort = std_sort, typename... Args>
|
|
|
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
|
|
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
|
|
|
- sort_n(static_cast<size_type>(end() - begin(0)), std::move(compare), std::move(algo), std::forward<Args>(args)...);
|
|
|
|
|
|
|
+ sort_n((mode == deletion_policy::swap_only) ? head : packed.size(), std::move(compare), std::move(algo), std::forward<Args>(args)...);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1044,7 +1044,7 @@ public:
|
|
|
template<typename It>
|
|
template<typename It>
|
|
|
iterator sort_as(It first, It last) {
|
|
iterator sort_as(It first, It last) {
|
|
|
ENTT_ASSERT((mode != deletion_policy::in_place) || (head == max_size), "Sorting with tombstones not allowed");
|
|
ENTT_ASSERT((mode != deletion_policy::in_place) || (head == max_size), "Sorting with tombstones not allowed");
|
|
|
- auto it = begin(0);
|
|
|
|
|
|
|
+ auto it = (mode == deletion_policy::swap_only) ? (end() - static_cast<typename iterator::difference_type>(head)) : begin();
|
|
|
|
|
|
|
|
for(const auto other = end(); (it != other) && (first != last); ++first) {
|
|
for(const auto other = end(); (it != other) && (first != last); ++first) {
|
|
|
if(const auto curr = *first; contains(curr)) {
|
|
if(const auto curr = *first; contains(curr)) {
|