diff --git a/src/entt/entity/observer.hpp b/src/entt/entity/observer.hpp index 12bf556c4..517a539ff 100644 --- a/src/entt/entity/observer.hpp +++ b/src/entt/entity/observer.hpp @@ -191,7 +191,7 @@ class basic_observer { template static void discard_if(basic_observer &obs, basic_registry &, const Entity entt) { if(auto *value = obs.view.try_get(entt); value && !(*value &= (~(1 << Index)))) { - obs.view.erase(entt); + obs.view.remove(entt); } } @@ -234,7 +234,7 @@ class basic_observer { template static void discard_if(basic_observer &obs, basic_registry &, const Entity entt) { if(auto *value = obs.view.try_get(entt); value && !(*value &= (~(1 << Index)))) { - obs.view.erase(entt); + obs.view.remove(entt); } } diff --git a/src/entt/entity/pool.hpp b/src/entt/entity/pool.hpp index 4a052148b..42bd76f4a 100644 --- a/src/entt/entity/pool.hpp +++ b/src/entt/entity/pool.hpp @@ -63,7 +63,7 @@ struct storage_adapter_mixin: Storage { */ template void remove(basic_registry &, const entity_type entity, Args &&... args) { - Storage::erase(entity, std::forward(args)...); + Storage::remove(entity, std::forward(args)...); } /** @@ -73,7 +73,7 @@ struct storage_adapter_mixin: Storage { * @param last An iterator past the last element of the range of entities. */ template - void remove(basic_registry &, It first, It last) { + void erase(basic_registry &, It first, It last) { Storage::erase(first, last); } @@ -227,14 +227,14 @@ struct sigh_pool_mixin: Pool { * @param last An iterator past the last element of the range of entities. */ template - void remove(basic_registry &owner, It first, It last) { + void erase(basic_registry &owner, It first, It last) { if(!destruction.empty()) { for(auto it = first; it != last; ++it) { destruction.publish(owner, *it); } } - Pool::remove(owner, first, last); + Pool::erase(owner, first, last); } /** diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 88680b100..c2686c8ac 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -45,7 +45,7 @@ class basic_registry { struct pool_data { type_info info{}; std::unique_ptr> pool{}; - void(* remove)(basic_sparse_set &, basic_registry &, const Entity *, const Entity *){}; + void(* erase)(basic_sparse_set &, basic_registry &, const Entity *, const Entity *){}; }; template @@ -79,7 +79,7 @@ class basic_registry { void discard_if([[maybe_unused]] basic_registry &owner, const Entity entt) { if constexpr(sizeof...(Owned) == 0) { if(current.contains(entt)) { - current.erase(entt); + current.remove(entt); } } else { if(const auto cpools = std::forward_as_tuple(owner.assure()...); std::get<0>(cpools).contains(entt) && (std::get<0>(cpools).index(entt) < current)) { @@ -114,8 +114,8 @@ class basic_registry { if(auto &&pdata = pools[index]; !pdata.pool) { pdata.info = type_id(); pdata.pool.reset(new pool_t()); - pdata.remove = +[](basic_sparse_set &cpool, basic_registry &owner, const Entity *first, const Entity *last) { - static_cast &>(cpool).remove(owner, first, last); + pdata.erase = +[](basic_sparse_set &cpool, basic_registry &owner, const Entity *first, const Entity *last) { + static_cast &>(cpool).erase(owner, first, last); }; } @@ -724,9 +724,9 @@ public: * @param last An iterator past the last element of the range of entities. */ template - void remove(It first, It last) { + void erase(It first, It last) { ENTT_ASSERT(std::all_of(first, last, [this](const auto entity) { return valid(entity); })); - (assure().remove(*this, first, last), ...); + (assure().erase(*this, first, last), ...); } /** @@ -780,7 +780,7 @@ public: for(auto pos = pools.size(); pos; --pos) { if(auto &pdata = pools[pos-1]; pdata.pool && pdata.pool->contains(entity)) { - pdata.remove(*pdata.pool, *this, std::begin(wrap), std::end(wrap)); + pdata.erase(*pdata.pool, *this, std::begin(wrap), std::end(wrap)); } } } @@ -937,7 +937,7 @@ public: if constexpr(sizeof...(Component) == 0) { for(auto pos = pools.size(); pos; --pos) { if(const auto &pdata = pools[pos-1]; pdata.pool) { - pdata.remove(*pdata.pool, *this, pdata.pool->rbegin(), pdata.pool->rend()); + pdata.erase(*pdata.pool, *this, pdata.pool->rbegin(), pdata.pool->rend()); } } @@ -948,7 +948,7 @@ public: } } else { ([this](auto &&cpool) { - cpool.remove(*this, cpool.basic_sparse_set::begin(), cpool.basic_sparse_set::end()); + cpool.erase(*this, cpool.basic_sparse_set::begin(), cpool.basic_sparse_set::end()); }(assure()), ...); } } diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index a0095ea1d..03f8d70e9 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -425,7 +425,7 @@ public: * * @param entt A valid entity identifier. */ - virtual void erase(const entity_type entt) { + virtual void remove(const entity_type entt) { ENTT_ASSERT(contains(entt)); const auto curr = page(entt); const auto pos = offset(entt); @@ -448,7 +448,7 @@ public: clear(); } else { for(; first != last; ++first) { - erase(*first); + remove(*first); } } } diff --git a/src/entt/entity/storage.hpp b/src/entt/entity/storage.hpp index e15178dde..8d4aab7a5 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -426,11 +426,11 @@ public: * * @param entt A valid entity identifier. */ - void erase(const entity_type entt) override { + void remove(const entity_type entt) override { auto other = std::move(instances.back()); instances[underlying_type::index(entt)] = std::move(other); instances.pop_back(); - underlying_type::erase(entt); + underlying_type::remove(entt); } /** diff --git a/test/benchmark/benchmark.cpp b/test/benchmark/benchmark.cpp index 91e683f3c..9e2bbe8f0 100644 --- a/test/benchmark/benchmark.cpp +++ b/test/benchmark/benchmark.cpp @@ -138,7 +138,7 @@ TEST(Benchmark, Remove) { timer.elapsed(); } -TEST(Benchmark, RemoveMany) { +TEST(Benchmark, EraseMany) { entt::registry registry; std::vector entities(1000000); @@ -149,11 +149,11 @@ TEST(Benchmark, RemoveMany) { timer timer; auto view = registry.view(); - registry.remove(++view.begin(), view.end()); + registry.erase(++view.begin(), view.end()); timer.elapsed(); } -TEST(Benchmark, RemoveAll) { +TEST(Benchmark, EraseAll) { entt::registry registry; std::vector entities(1000000); @@ -164,7 +164,7 @@ TEST(Benchmark, RemoveAll) { timer timer; auto view = registry.view(); - registry.remove(view.begin(), view.end()); + registry.erase(view.begin(), view.end()); timer.elapsed(); } diff --git a/test/entt/entity/registry.cpp b/test/entt/entity/registry.cpp index cd0ff3d81..f908e79d9 100644 --- a/test/entt/entity/registry.cpp +++ b/test/entt/entity/registry.cpp @@ -1195,7 +1195,7 @@ TEST(Registry, Insert) { ASSERT_EQ(registry.get(e2), 2.f); } -TEST(Registry, RangeRemove) { +TEST(Registry, Erase) { entt::registry registry; const auto e0 = registry.create(); @@ -1216,7 +1216,7 @@ TEST(Registry, RangeRemove) { ASSERT_TRUE(registry.has(e2)); const auto view = registry.view(); - registry.remove(view.begin(), view.end()); + registry.erase(view.begin(), view.end()); ASSERT_FALSE(registry.has(e0)); ASSERT_FALSE(registry.has(e1)); diff --git a/test/entt/entity/sparse_set.cpp b/test/entt/entity/sparse_set.cpp index 4ef43841e..c8d080cc6 100644 --- a/test/entt/entity/sparse_set.cpp +++ b/test/entt/entity/sparse_set.cpp @@ -36,7 +36,7 @@ TEST(SparseSet, Functionalities) { ASSERT_TRUE(set.contains(entt::entity{42})); ASSERT_EQ(set.index(entt::entity{42}), 0u); - set.erase(entt::entity{42}); + set.remove(entt::entity{42}); ASSERT_TRUE(set.empty()); ASSERT_EQ(set.size(), 0u); @@ -90,14 +90,14 @@ TEST(SparseSet, Pagination) { ASSERT_TRUE(set.contains(entt::entity{entt_per_page})); ASSERT_FALSE(set.contains(entt::entity{entt_per_page+1})); - set.erase(entt::entity{entt_per_page-1}); + set.remove(entt::entity{entt_per_page-1}); ASSERT_EQ(set.extent(), 2 * entt_per_page); ASSERT_FALSE(set.contains(entt::entity{entt_per_page-1})); ASSERT_TRUE(set.contains(entt::entity{entt_per_page})); set.shrink_to_fit(); - set.erase(entt::entity{entt_per_page}); + set.remove(entt::entity{entt_per_page}); ASSERT_EQ(set.extent(), 2 * entt_per_page); ASSERT_FALSE(set.contains(entt::entity{entt_per_page-1})); @@ -138,7 +138,7 @@ TEST(SparseSet, Insert) { ASSERT_EQ(set.data()[set.index(entt::entity{24})], entt::entity{24}); } -TEST(SparseSet, RangeErase) { +TEST(SparseSet, Erase) { entt::sparse_set set; entt::entity entities[3]; diff --git a/test/entt/entity/storage.cpp b/test/entt/entity/storage.cpp index 57a8c34c9..911768940 100644 --- a/test/entt/entity/storage.cpp +++ b/test/entt/entity/storage.cpp @@ -45,7 +45,7 @@ TEST(Storage, Functionalities) { ASSERT_EQ(*pool.try_get(entt::entity{41}), 3); ASSERT_EQ(pool.try_get(entt::entity{99}), nullptr); - pool.erase(entt::entity{41}); + pool.remove(entt::entity{41}); ASSERT_TRUE(pool.empty()); ASSERT_EQ(pool.size(), 0u); @@ -120,7 +120,7 @@ TEST(Storage, InsertEmptyType) { ASSERT_EQ(pool.size(), 2u); } -TEST(Storage, RangeErase) { +TEST(Storage, Erase) { entt::storage pool; entt::sparse_set &base = pool; @@ -160,7 +160,7 @@ TEST(Storage, TypesFromStandardTemplateLibraryMustWork) { // see #37 - this test shouldn't crash, that's all entt::storage> pool; pool.emplace(entt::entity{0}).insert(42); - pool.erase(entt::entity{0}); + pool.remove(entt::entity{0}); } TEST(Storage, Iterator) { diff --git a/test/example/multi_instance_storage.cpp b/test/example/multi_instance_storage.cpp index 230dd967b..177ec4999 100644 --- a/test/example/multi_instance_storage.cpp +++ b/test/example/multi_instance_storage.cpp @@ -22,9 +22,9 @@ struct multi_instance_storage: entt::basic_storage> { using iterator = typename underlying_storage::iterator; using const_iterator = typename underlying_storage::const_iterator; - template - void insert(Args &&...) = delete; + template void insert(Args &&...) = delete; + using underlying_storage::remove; using underlying_storage::erase; template @@ -38,12 +38,12 @@ struct multi_instance_storage: entt::basic_storage> { return vec->emplace_back(Type{std::forward(args)...}); } - void erase(const entity_type entt, const size_type index) { + void remove(const entity_type entt, const size_type index) { auto &vec = underlying_storage::get(entt); vec.erase(vec.begin() + index); if(vec.empty()) { - underlying_storage::erase(entt); + underlying_storage::remove(entt); } } };