ソースを参照

sparse_set: prepare for detached pools

Michele Caini 5 年 前
コミット
0fcf0142ba
2 ファイル変更3 行追加15 行削除
  1. 3 11
      src/entt/entity/sparse_set.hpp
  2. 0 4
      src/entt/entity/storage.hpp

+ 3 - 11
src/entt/entity/sparse_set.hpp

@@ -175,7 +175,6 @@ class basic_sparse_set {
 
 
     virtual void swap_at(const std::size_t, const std::size_t) {}
     virtual void swap_at(const std::size_t, const std::size_t) {}
     virtual void swap_and_pop(const std::size_t) {}
     virtual void swap_and_pop(const std::size_t) {}
-    virtual void clear_all() {}
 
 
 public:
 public:
     /*! @brief Underlying entity identifier. */
     /*! @brief Underlying entity identifier. */
@@ -443,13 +442,8 @@ public:
      */
      */
     template<typename It>
     template<typename It>
     void remove(It first, It last) {
     void remove(It first, It last) {
-        if(std::distance(first, last) == std::distance(packed.begin(), packed.end())) {
-            // no validity check, let it be misused
-            clear();
-        } else {
-            for(; first != last; ++first) {
-                remove(*first);
-            }
+        for(; first != last; ++first) {
+            remove(*first);
         }
         }
     }
     }
 
 
@@ -577,9 +571,7 @@ public:
 
 
     /*! @brief Clears a sparse set. */
     /*! @brief Clears a sparse set. */
     void clear() ENTT_NOEXCEPT {
     void clear() ENTT_NOEXCEPT {
-        sparse.clear();
-        packed.clear();
-        clear_all();
+        remove(rbegin(), rend());
     }
     }
 
 
 private:
 private:

+ 0 - 4
src/entt/entity/storage.hpp

@@ -174,10 +174,6 @@ class basic_storage: public basic_sparse_set<Entity> {
         instances.pop_back();
         instances.pop_back();
     }
     }
 
 
-    void clear_all() ENTT_NOEXCEPT final {
-        instances.clear();
-    }
-
 public:
 public:
     /*! @brief Type of the objects associated with the entities. */
     /*! @brief Type of the objects associated with the entities. */
     using value_type = Type;
     using value_type = Type;