Browse Source

group: iterator based sort_as

Michele Caini 2 years ago
parent
commit
7ddef2586c
1 changed files with 15 additions and 4 deletions
  1. 15 4
      src/entt/entity/group.hpp

+ 15 - 4
src/entt/entity/group.hpp

@@ -650,19 +650,30 @@ public:
     }
 
     /**
-     * @brief Sort the shared pool of entities according to a given storage.
+     * @brief Sort entities according to their order in a range.
      *
      * The shared pool of entities and thus its order is affected by the changes
      * to each and every pool that it tracks.
      *
-     * @param other The storage to use to impose the order.
+     * @tparam It Type of input iterator.
+     * @param first An iterator to the first element of the range of entities.
+     * @param last An iterator past the last element of the range of entities.
      */
-    void sort_as(const common_type &other) const {
+    template<typename It>
+    void sort_as(It first, It last) const {
         if(*this) {
-            descriptor->handle().sort_as(other);
+            descriptor->handle().sort_as(first, last);
         }
     }
 
+    /**
+     * @brief Sort entities according to their order in a range.
+     * @param other The storage to use to impose the order.
+     */
+    [[deprecated("use iterator based sort_as instead")]] void sort_as(const common_type &other) const {
+        sort_as(other.begin(), other.end());
+    }
+
 private:
     handler *descriptor;
 };