*: in_use -> free_list
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
archive(static_cast<typename traits_type::entity_type>(storage->size()));
|
||||
|
||||
if constexpr(std::is_same_v<Type, entity_type>) {
|
||||
archive(static_cast<typename traits_type::entity_type>(storage->in_use()));
|
||||
archive(static_cast<typename traits_type::entity_type>(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<Type, entity_type>) {
|
||||
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>();
|
||||
entity_type entt{null};
|
||||
|
||||
@@ -216,7 +216,7 @@ TEST(BasicHandle, Lifetime) {
|
||||
handle->emplace<int>();
|
||||
|
||||
ASSERT_FALSE(registry.storage<int>().empty());
|
||||
ASSERT_NE(registry.storage<entt::entity>().in_use(), 0u);
|
||||
ASSERT_NE(registry.storage<entt::entity>().free_list(), 0u);
|
||||
|
||||
for(auto [entt]: registry.storage<entt::entity>().each()) {
|
||||
ASSERT_EQ(handle->entity(), entt);
|
||||
@@ -225,7 +225,7 @@ TEST(BasicHandle, Lifetime) {
|
||||
delete handle;
|
||||
|
||||
ASSERT_FALSE(registry.storage<int>().empty());
|
||||
ASSERT_NE(registry.storage<entt::entity>().in_use(), 0u);
|
||||
ASSERT_NE(registry.storage<entt::entity>().free_list(), 0u);
|
||||
}
|
||||
|
||||
TEST(BasicHandle, ImplicitConversions) {
|
||||
|
||||
@@ -242,7 +242,7 @@ TEST(Registry, Functionalities) {
|
||||
ASSERT_NO_FATAL_FAILURE([[maybe_unused]] auto alloc = registry.get_allocator());
|
||||
|
||||
ASSERT_EQ(registry.storage<entt::entity>().size(), 0u);
|
||||
ASSERT_EQ(registry.storage<entt::entity>().in_use(), 0u);
|
||||
ASSERT_EQ(registry.storage<entt::entity>().free_list(), 0u);
|
||||
ASSERT_NO_FATAL_FAILURE(registry.storage<entt::entity>().reserve(42));
|
||||
ASSERT_EQ(registry.storage<entt::entity>().capacity(), 42u);
|
||||
ASSERT_TRUE(registry.storage<entt::entity>().empty());
|
||||
@@ -324,7 +324,7 @@ TEST(Registry, Functionalities) {
|
||||
ASSERT_EQ(static_cast<const entt::registry &>(registry).get<int>(e1), 1);
|
||||
|
||||
ASSERT_EQ(registry.storage<entt::entity>().size(), 3u);
|
||||
ASSERT_EQ(registry.storage<entt::entity>().in_use(), 3u);
|
||||
ASSERT_EQ(registry.storage<entt::entity>().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<entt::entity>().size(), 3u);
|
||||
ASSERT_EQ(registry.storage<entt::entity>().in_use(), 2u);
|
||||
ASSERT_EQ(registry.storage<entt::entity>().free_list(), 2u);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(registry.clear());
|
||||
|
||||
ASSERT_EQ(registry.storage<entt::entity>().size(), 3u);
|
||||
ASSERT_EQ(registry.storage<entt::entity>().in_use(), 0u);
|
||||
ASSERT_EQ(registry.storage<entt::entity>().free_list(), 0u);
|
||||
ASSERT_FALSE(registry.storage<entt::entity>().empty());
|
||||
|
||||
const auto e3 = registry.create();
|
||||
@@ -630,7 +630,7 @@ TEST(Registry, CreateDestroyReleaseCornerCase) {
|
||||
registry.destroy(e0);
|
||||
registry.storage<entt::entity>().erase(e1);
|
||||
|
||||
ASSERT_EQ(registry.storage<entt::entity>().in_use(), 0u);
|
||||
ASSERT_EQ(registry.storage<entt::entity>().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<entt::entity>();
|
||||
|
||||
dst.push(src.rbegin(), src.rend());
|
||||
dst.in_use(src.in_use());
|
||||
dst.free_list(src.free_list());
|
||||
|
||||
ASSERT_EQ(registry.storage<entt::entity>().size(), other.storage<entt::entity>().size());
|
||||
ASSERT_TRUE(other.valid(entity[0]));
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -57,7 +57,7 @@ TEST(BasicSnapshot, GetEntityType) {
|
||||
ASSERT_EQ(entt::any_cast<typename traits_type::entity_type>(data[0u]), storage.size());
|
||||
|
||||
ASSERT_NE(entt::any_cast<typename traits_type::entity_type>(&data[1u]), nullptr);
|
||||
ASSERT_EQ(entt::any_cast<typename traits_type::entity_type>(data[1u]), storage.in_use());
|
||||
ASSERT_EQ(entt::any_cast<typename traits_type::entity_type>(data[1u]), storage.free_list());
|
||||
|
||||
entt::entity entity[3u];
|
||||
|
||||
@@ -73,7 +73,7 @@ TEST(BasicSnapshot, GetEntityType) {
|
||||
ASSERT_EQ(entt::any_cast<typename traits_type::entity_type>(data[0u]), storage.size());
|
||||
|
||||
ASSERT_NE(entt::any_cast<typename traits_type::entity_type>(&data[1u]), nullptr);
|
||||
ASSERT_EQ(entt::any_cast<typename traits_type::entity_type>(data[1u]), storage.in_use());
|
||||
ASSERT_EQ(entt::any_cast<typename traits_type::entity_type>(data[1u]), storage.free_list());
|
||||
|
||||
ASSERT_NE(entt::any_cast<entt::entity>(&data[2u]), nullptr);
|
||||
ASSERT_EQ(entt::any_cast<entt::entity>(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<typename traits_type::entity_type>(3u));
|
||||
data.emplace_back(static_cast<typename traits_type::entity_type>(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::entity>(entt::null));
|
||||
|
||||
ASSERT_EQ(storage.size(), 0u);
|
||||
ASSERT_EQ(storage.in_use(), 0u);
|
||||
ASSERT_EQ(storage.free_list(), 0u);
|
||||
|
||||
data.emplace_back(static_cast<typename traits_type::entity_type>(3u));
|
||||
data.emplace_back(static_cast<typename traits_type::entity_type>(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]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user