Просмотр исходного кода

range destroy is now named destroy_each for consistency

Michele Caini 6 лет назад
Родитель
Сommit
9cf64ba881
4 измененных файлов с 11 добавлено и 10 удалено
  1. 1 1
      TODO
  2. 7 6
      docs/md/entity.md
  3. 1 1
      src/entt/entity/registry.hpp
  4. 2 2
      test/entt/entity/registry.cpp

+ 1 - 1
TODO

@@ -38,6 +38,6 @@
 * meta: are fake types not backed by actual types possible?
 * named types: almost-stable index optimization for direct access to pools, no more linear searches
 * multi component registry::remove and some others?
-  - range destroy and range stomp -> destroy_each, stomp_each
+  - range stomp -> stomp_each
   - remove create overload for spwaning
   - clean up stomp functions

+ 7 - 6
docs/md/entity.md

@@ -184,14 +184,15 @@ auto entity = registry.create();
 registry.destroy(entity);
 ```
 
-There exists also an overload of the `create` and `destroy` member functions
-that accepts two iterators, that is a range to assign or to destroy. It can be
-used to create or destroy multiple entities at once:
+The `create` member function has also an overload that accepts two iterators and
+can be used to generate multiple entities at once efficiently. Similarly, the
+`destroy_each` member function works with a range of entities and destroys them
+all:
 
 ```cpp
 // destroys all the entities in a range
 auto view = registry.view<a_component, another_component>();
-registry.destroy(view.begin(), view.end());
+registry.destroy_each(view.begin(), view.end());
 ```
 
 In both cases, the `create` member function accepts also a list of default
@@ -235,8 +236,8 @@ vel.dx = 0.;
 vel.dy = 0.;
 ```
 
-Similarly, the `assign_each` member function accepts two iterators, that is a
-range of entities to which to assign the component.
+Similarly, the `assign_each` member function template accepts two iterators,
+that is a range of entities to which to assign a component.
 
 If an entity already has the given component, the `replace` member function
 template can be used to replace it:

+ 1 - 1
src/entt/entity/registry.hpp

@@ -703,7 +703,7 @@ public:
      * @param last An iterator past the last element of the range to destroy.
      */
     template<typename It>
-    void destroy(It first, It last) {
+    void destroy_each(It first, It last) {
         // useless this-> used to suppress a warning with clang
         std::for_each(first, last, [this](const auto entity) { this->destroy(entity); });
     }

+ 2 - 2
test/entt/entity/registry.cpp

@@ -1046,7 +1046,7 @@ TEST(Registry, RangeDestroy) {
 
     {
         const auto view = registry.view<int, char>();
-        registry.destroy(view.begin(), view.end());
+        registry.destroy_each(view.begin(), view.end());
     }
 
     ASSERT_FALSE(registry.valid(e0));
@@ -1055,7 +1055,7 @@ TEST(Registry, RangeDestroy) {
 
     {
         const auto view = registry.view<int>();
-        registry.destroy(view.begin(), view.end());
+        registry.destroy_each(view.begin(), view.end());
     }
 
     ASSERT_FALSE(registry.valid(e0));