From 46ccded145ee1dcdd3849d770ed77b7d430349b3 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 14 Sep 2023 23:34:59 +0200 Subject: [PATCH] *: in_use -> free_list --- src/entt/entity/registry.hpp | 2 +- src/entt/entity/snapshot.hpp | 8 ++++---- test/entt/entity/handle.cpp | 4 ++-- test/entt/entity/registry.cpp | 12 ++++++------ test/entt/entity/sigh_mixin.cpp | 12 ++++++------ test/entt/entity/snapshot.cpp | 16 ++++++++-------- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 203079f37..e49f0212d 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -462,7 +462,7 @@ public: * @return True if the identifier is valid, false otherwise. */ [[nodiscard]] bool valid(const entity_type entt) const { - return entities.contains(entt) && (entities.index(entt) < entities.in_use()); + return entities.contains(entt) && (entities.index(entt) < entities.free_list()); } /** diff --git a/src/entt/entity/snapshot.hpp b/src/entt/entity/snapshot.hpp index 0629594a0..68b06411a 100644 --- a/src/entt/entity/snapshot.hpp +++ b/src/entt/entity/snapshot.hpp @@ -89,7 +89,7 @@ public: archive(static_cast(storage->size())); if constexpr(std::is_same_v) { - archive(static_cast(storage->in_use())); + archive(static_cast(storage->free_list())); for(auto first = storage->data(), last = first + storage->size(); first != last; ++first) { archive(*first); @@ -197,17 +197,17 @@ public: archive(length); if constexpr(std::is_same_v) { - typename traits_type::entity_type in_use{}; + typename traits_type::entity_type count{}; storage.reserve(length); - archive(in_use); + archive(count); for(entity_type entity = null; length; --length) { archive(entity); storage.emplace(entity); } - storage.in_use(in_use); + storage.free_list(count); } else { auto &other = reg->template storage(); entity_type entt{null}; diff --git a/test/entt/entity/handle.cpp b/test/entt/entity/handle.cpp index 2a76898cb..258dfabae 100644 --- a/test/entt/entity/handle.cpp +++ b/test/entt/entity/handle.cpp @@ -216,7 +216,7 @@ TEST(BasicHandle, Lifetime) { handle->emplace(); ASSERT_FALSE(registry.storage().empty()); - ASSERT_NE(registry.storage().in_use(), 0u); + ASSERT_NE(registry.storage().free_list(), 0u); for(auto [entt]: registry.storage().each()) { ASSERT_EQ(handle->entity(), entt); @@ -225,7 +225,7 @@ TEST(BasicHandle, Lifetime) { delete handle; ASSERT_FALSE(registry.storage().empty()); - ASSERT_NE(registry.storage().in_use(), 0u); + ASSERT_NE(registry.storage().free_list(), 0u); } TEST(BasicHandle, ImplicitConversions) { diff --git a/test/entt/entity/registry.cpp b/test/entt/entity/registry.cpp index 075070280..30c9f12f5 100644 --- a/test/entt/entity/registry.cpp +++ b/test/entt/entity/registry.cpp @@ -242,7 +242,7 @@ TEST(Registry, Functionalities) { ASSERT_NO_FATAL_FAILURE([[maybe_unused]] auto alloc = registry.get_allocator()); ASSERT_EQ(registry.storage().size(), 0u); - ASSERT_EQ(registry.storage().in_use(), 0u); + ASSERT_EQ(registry.storage().free_list(), 0u); ASSERT_NO_FATAL_FAILURE(registry.storage().reserve(42)); ASSERT_EQ(registry.storage().capacity(), 42u); ASSERT_TRUE(registry.storage().empty()); @@ -324,7 +324,7 @@ TEST(Registry, Functionalities) { ASSERT_EQ(static_cast(registry).get(e1), 1); ASSERT_EQ(registry.storage().size(), 3u); - ASSERT_EQ(registry.storage().in_use(), 3u); + ASSERT_EQ(registry.storage().free_list(), 3u); ASSERT_EQ(traits_type::to_version(e2), 0u); ASSERT_EQ(registry.current(e2), 0u); @@ -337,12 +337,12 @@ TEST(Registry, Functionalities) { ASSERT_FALSE(registry.valid(e2)); ASSERT_EQ(registry.storage().size(), 3u); - ASSERT_EQ(registry.storage().in_use(), 2u); + ASSERT_EQ(registry.storage().free_list(), 2u); ASSERT_NO_FATAL_FAILURE(registry.clear()); ASSERT_EQ(registry.storage().size(), 3u); - ASSERT_EQ(registry.storage().in_use(), 0u); + ASSERT_EQ(registry.storage().free_list(), 0u); ASSERT_FALSE(registry.storage().empty()); const auto e3 = registry.create(); @@ -630,7 +630,7 @@ TEST(Registry, CreateDestroyReleaseCornerCase) { registry.destroy(e0); registry.storage().erase(e1); - ASSERT_EQ(registry.storage().in_use(), 0u); + ASSERT_EQ(registry.storage().free_list(), 0u); ASSERT_EQ(registry.current(e0), 1u); ASSERT_EQ(registry.current(e1), 1u); @@ -2012,7 +2012,7 @@ TEST(Registry, AssignEntities) { auto &dst = other.storage(); dst.push(src.rbegin(), src.rend()); - dst.in_use(src.in_use()); + dst.free_list(src.free_list()); ASSERT_EQ(registry.storage().size(), other.storage().size()); ASSERT_TRUE(other.valid(entity[0])); diff --git a/test/entt/entity/sigh_mixin.cpp b/test/entt/entity/sigh_mixin.cpp index 2a9ff80f1..ef7fadaaf 100644 --- a/test/entt/entity/sigh_mixin.cpp +++ b/test/entt/entity/sigh_mixin.cpp @@ -481,14 +481,14 @@ TEST(SighMixin, StorageEntity) { ASSERT_EQ(on_construct.value, 1); ASSERT_EQ(on_destroy.value, 0); ASSERT_EQ(pool.size(), 2u); - ASSERT_EQ(pool.in_use(), 1u); + ASSERT_EQ(pool.free_list(), 1u); pool.erase(entt::entity{1}); ASSERT_EQ(on_construct.value, 1); ASSERT_EQ(on_destroy.value, 1); ASSERT_EQ(pool.size(), 2u); - ASSERT_EQ(pool.in_use(), 0u); + ASSERT_EQ(pool.free_list(), 0u); pool.push(traits_type::construct(0, 2)); pool.push(traits_type::construct(2, 1)); @@ -500,12 +500,12 @@ TEST(SighMixin, StorageEntity) { ASSERT_EQ(on_construct.value, 3); ASSERT_EQ(on_destroy.value, 1); ASSERT_EQ(pool.size(), 3u); - ASSERT_EQ(pool.in_use(), 2u); + ASSERT_EQ(pool.free_list(), 2u); pool.clear(); ASSERT_EQ(pool.size(), 0u); - ASSERT_EQ(pool.in_use(), 0u); + ASSERT_EQ(pool.free_list(), 0u); ASSERT_EQ(on_construct.value, 3); ASSERT_EQ(on_destroy.value, 3); @@ -519,12 +519,12 @@ TEST(SighMixin, StorageEntity) { ASSERT_EQ(on_construct.value, 6); ASSERT_EQ(on_destroy.value, 3); ASSERT_EQ(pool.size(), 3u); - ASSERT_EQ(pool.in_use(), 3u); + ASSERT_EQ(pool.free_list(), 3u); pool.clear(); ASSERT_EQ(pool.size(), 0u); - ASSERT_EQ(pool.in_use(), 0u); + ASSERT_EQ(pool.free_list(), 0u); } TEST(SighMixin, CustomAllocator) { diff --git a/test/entt/entity/snapshot.cpp b/test/entt/entity/snapshot.cpp index 3a8c68c1d..79b6e9d46 100644 --- a/test/entt/entity/snapshot.cpp +++ b/test/entt/entity/snapshot.cpp @@ -57,7 +57,7 @@ TEST(BasicSnapshot, GetEntityType) { ASSERT_EQ(entt::any_cast(data[0u]), storage.size()); ASSERT_NE(entt::any_cast(&data[1u]), nullptr); - ASSERT_EQ(entt::any_cast(data[1u]), storage.in_use()); + ASSERT_EQ(entt::any_cast(data[1u]), storage.free_list()); entt::entity entity[3u]; @@ -73,7 +73,7 @@ TEST(BasicSnapshot, GetEntityType) { ASSERT_EQ(entt::any_cast(data[0u]), storage.size()); ASSERT_NE(entt::any_cast(&data[1u]), nullptr); - ASSERT_EQ(entt::any_cast(data[1u]), storage.in_use()); + ASSERT_EQ(entt::any_cast(data[1u]), storage.free_list()); ASSERT_NE(entt::any_cast(&data[2u]), nullptr); ASSERT_EQ(entt::any_cast(data[2u]), storage.data()[0u]); @@ -265,7 +265,7 @@ TEST(BasicSnapshotLoader, GetEntityType) { ASSERT_FALSE(registry.valid(entity[2u])); ASSERT_EQ(storage.size(), 0u); - ASSERT_EQ(storage.in_use(), 0u); + ASSERT_EQ(storage.free_list(), 0u); data.emplace_back(static_cast(3u)); data.emplace_back(static_cast(2u)); @@ -281,7 +281,7 @@ TEST(BasicSnapshotLoader, GetEntityType) { ASSERT_FALSE(registry.valid(entity[2u])); ASSERT_EQ(storage.size(), 3u); - ASSERT_EQ(storage.in_use(), 2u); + ASSERT_EQ(storage.free_list(), 2u); ASSERT_EQ(storage[0u], entity[0u]); ASSERT_EQ(storage[1u], entity[1u]); @@ -542,7 +542,7 @@ TEST(BasicContinuousLoader, GetEntityType) { ASSERT_EQ(loader.map(entity[2u]), static_cast(entt::null)); ASSERT_EQ(storage.size(), 0u); - ASSERT_EQ(storage.in_use(), 0u); + ASSERT_EQ(storage.free_list(), 0u); data.emplace_back(static_cast(3u)); data.emplace_back(static_cast(2u)); @@ -565,7 +565,7 @@ TEST(BasicContinuousLoader, GetEntityType) { ASSERT_TRUE(registry.valid(loader.map(entity[1u]))); ASSERT_EQ(storage.size(), 2u); - ASSERT_EQ(storage.in_use(), 2u); + ASSERT_EQ(storage.free_list(), 2u); ASSERT_EQ(storage[0u], loader.map(entity[0u])); ASSERT_EQ(storage[1u], loader.map(entity[1u])); @@ -594,7 +594,7 @@ TEST(BasicContinuousLoader, GetEntityType) { ASSERT_TRUE(registry.valid(loader.map(entity[2u]))); ASSERT_EQ(storage.size(), 4u); - ASSERT_EQ(storage.in_use(), 4u); + ASSERT_EQ(storage.free_list(), 4u); ASSERT_EQ(storage[0u], loader.map(entity[0u])); ASSERT_EQ(storage[1u], loader.map(entity[1u])); @@ -638,7 +638,7 @@ TEST(BasicContinuousLoader, GetEntityType) { ASSERT_TRUE(registry.valid(loader.map(entity[1u]))); ASSERT_EQ(storage.size(), 4u); - ASSERT_EQ(storage.in_use(), 2u); + ASSERT_EQ(storage.free_list(), 2u); ASSERT_EQ(storage[1u], loader.map(entity[1u])); }