updated sparse_set interface
This commit is contained in:
@@ -840,10 +840,10 @@ public:
|
||||
|
||||
for(auto next = *length; next; --next) {
|
||||
([next = next-1, curr = cpool->data()[next-1]](auto *cpool) {
|
||||
const auto pos = cpool->sparse_set<entity_type>::get(curr);
|
||||
const auto pos = cpool->index(curr);
|
||||
|
||||
if(pos != next) {
|
||||
cpool->swap(next, cpool->sparse_set<entity_type>::get(curr));
|
||||
cpool->swap(next, cpool->index(curr));
|
||||
}
|
||||
}(std::get<pool_type<Other> *>(pools)), ...);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ class basic_registry {
|
||||
&& !(std::get<pool_type<Exclude> *>(cpools)->has(entt) || ...))
|
||||
{
|
||||
const auto pos = this->owned++;
|
||||
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->sparse_set<Entity>::get(entt), pos), ...);
|
||||
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->index(entt), pos), ...);
|
||||
}
|
||||
} else if constexpr(std::disjunction_v<std::is_same<Exclude, Component>...>) {
|
||||
if((std::get<pool_type<Owned> *>(cpools)->has(entt) && ...)
|
||||
@@ -176,15 +176,15 @@ class basic_registry {
|
||||
&& ((std::is_same_v<Exclude, Component> || !std::get<pool_type<Exclude> *>(cpools)->has(entt)) && ...))
|
||||
{
|
||||
const auto pos = this->owned++;
|
||||
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->sparse_set<Entity>::get(entt), pos), ...);
|
||||
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->index(entt), pos), ...);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void discard_if(const Entity entt) {
|
||||
if(std::get<0>(cpools)->has(entt) && std::get<0>(cpools)->sparse_set<Entity>::get(entt) < this->owned) {
|
||||
if(std::get<0>(cpools)->has(entt) && std::get<0>(cpools)->index(entt) < this->owned) {
|
||||
const auto pos = --this->owned;
|
||||
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->sparse_set<Entity>::get(entt), pos), ...);
|
||||
(std::get<pool_type<Owned> *>(cpools)->swap(std::get<pool_type<Owned> *>(cpools)->index(entt), pos), ...);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1403,7 +1403,7 @@ public:
|
||||
} else {
|
||||
const auto pos = curr->owned++;
|
||||
// useless this-> used to suppress a warning with clang
|
||||
(std::get<pool_type<Owned> *>(curr->cpools)->swap(std::get<pool_type<Owned> *>(curr->cpools)->sparse_set<Entity>::get(entity), pos), ...);
|
||||
(std::get<pool_type<Owned> *>(curr->cpools)->swap(std::get<pool_type<Owned> *>(curr->cpools)->index(entity), pos), ...);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -166,7 +166,7 @@ class sparse_set {
|
||||
}
|
||||
}
|
||||
|
||||
auto index(const Entity entt) const ENTT_NOEXCEPT {
|
||||
auto map(const Entity entt) const ENTT_NOEXCEPT {
|
||||
const auto identifier = to_integer(entt) & traits_type::entity_mask;
|
||||
const auto page = size_type(identifier / entt_per_page);
|
||||
const auto offset = size_type(identifier & (entt_per_page - 1));
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
*
|
||||
* @param cap Desired capacity.
|
||||
*/
|
||||
virtual void reserve(const size_type cap) {
|
||||
void reserve(const size_type cap) {
|
||||
direct.reserve(cap);
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ public:
|
||||
}
|
||||
|
||||
/*! @brief Requests the removal of unused capacity. */
|
||||
virtual void shrink_to_fit() {
|
||||
void shrink_to_fit() {
|
||||
// conservative approach
|
||||
if(direct.empty()) {
|
||||
reverse.clear();
|
||||
@@ -353,7 +353,7 @@ public:
|
||||
* iterator otherwise.
|
||||
*/
|
||||
iterator_type find(const entity_type entt) const ENTT_NOEXCEPT {
|
||||
return has(entt) ? --(end() - get(entt)) : end();
|
||||
return has(entt) ? --(end() - index(entt)) : end();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,7 +362,7 @@ public:
|
||||
* @return True if the sparse set contains the entity, false otherwise.
|
||||
*/
|
||||
bool has(const entity_type entt) const ENTT_NOEXCEPT {
|
||||
auto [page, offset] = index(entt);
|
||||
auto [page, offset] = map(entt);
|
||||
// testing against null permits to avoid accessing the direct vector
|
||||
return (page < reverse.size() && reverse[page] && reverse[page][offset] != null);
|
||||
}
|
||||
@@ -379,9 +379,9 @@ public:
|
||||
* @param entt A valid entity identifier.
|
||||
* @return The position of the entity in the sparse set.
|
||||
*/
|
||||
size_type get(const entity_type entt) const ENTT_NOEXCEPT {
|
||||
size_type index(const entity_type entt) const ENTT_NOEXCEPT {
|
||||
ENTT_ASSERT(has(entt));
|
||||
auto [page, offset] = index(entt);
|
||||
auto [page, offset] = map(entt);
|
||||
return size_type(reverse[page][offset]);
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ public:
|
||||
*/
|
||||
void construct(const entity_type entt) {
|
||||
ENTT_ASSERT(!has(entt));
|
||||
auto [page, offset] = index(entt);
|
||||
auto [page, offset] = map(entt);
|
||||
assure(page);
|
||||
reverse[page][offset] = entity_type(direct.size());
|
||||
direct.push_back(entt);
|
||||
@@ -421,7 +421,7 @@ public:
|
||||
void batch(It first, It last) {
|
||||
std::for_each(std::make_reverse_iterator(last), std::make_reverse_iterator(first), [this, next = direct.size()](const auto entt) mutable {
|
||||
ENTT_ASSERT(!has(entt));
|
||||
auto [page, offset] = index(entt);
|
||||
auto [page, offset] = map(entt);
|
||||
assure(page);
|
||||
reverse[page][offset] = entity_type(next++);
|
||||
});
|
||||
@@ -440,10 +440,10 @@ public:
|
||||
*
|
||||
* @param entt A valid entity identifier.
|
||||
*/
|
||||
virtual void destroy(const entity_type entt) {
|
||||
void destroy(const entity_type entt) {
|
||||
ENTT_ASSERT(has(entt));
|
||||
auto [from_page, from_offset] = index(entt);
|
||||
auto [to_page, to_offset] = index(direct.back());
|
||||
auto [from_page, from_offset] = map(entt);
|
||||
auto [to_page, to_offset] = map(direct.back());
|
||||
direct[size_type(reverse[from_page][from_offset])] = entity_type(direct.back());
|
||||
reverse[to_page][to_offset] = reverse[from_page][from_offset];
|
||||
reverse[from_page][from_offset] = null;
|
||||
@@ -468,8 +468,8 @@ public:
|
||||
virtual void swap(const size_type lhs, const size_type rhs) ENTT_NOEXCEPT {
|
||||
ENTT_ASSERT(lhs < direct.size());
|
||||
ENTT_ASSERT(rhs < direct.size());
|
||||
auto [src_page, src_offset] = index(direct[lhs]);
|
||||
auto [dst_page, dst_offset] = index(direct[rhs]);
|
||||
auto [src_page, src_offset] = map(direct[lhs]);
|
||||
auto [dst_page, dst_offset] = map(direct[rhs]);
|
||||
std::swap(reverse[src_page][src_offset], reverse[dst_page][dst_offset]);
|
||||
std::swap(direct[lhs], direct[rhs]);
|
||||
}
|
||||
@@ -570,7 +570,7 @@ public:
|
||||
while(pos && from != to) {
|
||||
if(has(*from)) {
|
||||
if(*from != direct[pos]) {
|
||||
swap(pos, get(*from));
|
||||
swap(pos, index(*from));
|
||||
}
|
||||
|
||||
--pos;
|
||||
@@ -583,7 +583,7 @@ public:
|
||||
/**
|
||||
* @brief Resets a sparse set.
|
||||
*/
|
||||
virtual void reset() {
|
||||
void reset() {
|
||||
reverse.clear();
|
||||
direct.clear();
|
||||
}
|
||||
|
||||
@@ -174,13 +174,13 @@ public:
|
||||
*
|
||||
* @param cap Desired capacity.
|
||||
*/
|
||||
void reserve(const size_type cap) override {
|
||||
void reserve(const size_type cap) {
|
||||
underlying_type::reserve(cap);
|
||||
instances.reserve(cap);
|
||||
}
|
||||
|
||||
/*! @brief Requests the removal of unused capacity. */
|
||||
void shrink_to_fit() override {
|
||||
void shrink_to_fit() {
|
||||
underlying_type::shrink_to_fit();
|
||||
instances.shrink_to_fit();
|
||||
}
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
* @return The object associated with the entity.
|
||||
*/
|
||||
const object_type & get(const entity_type entt) const ENTT_NOEXCEPT {
|
||||
return instances[underlying_type::get(entt)];
|
||||
return instances[underlying_type::index(entt)];
|
||||
}
|
||||
|
||||
/*! @copydoc get */
|
||||
@@ -292,7 +292,7 @@ public:
|
||||
* @return The object associated with the entity, if any.
|
||||
*/
|
||||
const object_type * try_get(const entity_type entt) const ENTT_NOEXCEPT {
|
||||
return underlying_type::has(entt) ? (instances.data() + underlying_type::get(entt)) : nullptr;
|
||||
return underlying_type::has(entt) ? (instances.data() + underlying_type::index(entt)) : nullptr;
|
||||
}
|
||||
|
||||
/*! @copydoc try_get */
|
||||
@@ -391,9 +391,9 @@ public:
|
||||
*
|
||||
* @param entt A valid entity identifier.
|
||||
*/
|
||||
void destroy(const entity_type entt) override {
|
||||
void destroy(const entity_type entt) {
|
||||
auto other = std::move(instances.back());
|
||||
instances[underlying_type::get(entt)] = std::move(other);
|
||||
instances[underlying_type::index(entt)] = std::move(other);
|
||||
instances.pop_back();
|
||||
underlying_type::destroy(entt);
|
||||
}
|
||||
@@ -472,7 +472,7 @@ public:
|
||||
static_assert(!std::is_empty_v<object_type>);
|
||||
|
||||
underlying_type::sort(from, to, [this, compare = std::move(compare)](const auto lhs, const auto rhs) {
|
||||
return compare(std::as_const(instances[underlying_type::get(lhs)]), std::as_const(instances[underlying_type::get(rhs)]));
|
||||
return compare(std::as_const(instances[underlying_type::index(lhs)]), std::as_const(instances[underlying_type::index(rhs)]));
|
||||
}, std::move(algo), std::forward<Args>(args)...);
|
||||
} else {
|
||||
underlying_type::sort(from, to, std::move(compare), std::move(algo), std::forward<Args>(args)...);
|
||||
@@ -480,7 +480,7 @@ public:
|
||||
}
|
||||
|
||||
/*! @brief Resets a storage. */
|
||||
void reset() override {
|
||||
void reset() {
|
||||
underlying_type::reset();
|
||||
instances.clear();
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ class basic_view {
|
||||
}
|
||||
|
||||
bool valid() const ENTT_NOEXCEPT {
|
||||
return std::all_of(unchecked.cbegin(), unchecked.cend(), [entt = *begin](const sparse_set<Entity> *view) {
|
||||
return view->has(entt);
|
||||
return std::all_of(unchecked.cbegin(), unchecked.cend(), [this](const sparse_set<Entity> *view) {
|
||||
return view->has(*begin);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ TEST(SparseSet, Functionalities) {
|
||||
|
||||
set.construct(entt::entity{42});
|
||||
|
||||
ASSERT_EQ(set.get(entt::entity{42}), 0u);
|
||||
ASSERT_EQ(set.index(entt::entity{42}), 0u);
|
||||
|
||||
ASSERT_FALSE(set.empty());
|
||||
ASSERT_EQ(set.size(), 1u);
|
||||
@@ -32,7 +32,7 @@ TEST(SparseSet, Functionalities) {
|
||||
ASSERT_NE(set.begin(), set.end());
|
||||
ASSERT_FALSE(set.has(entt::entity{0}));
|
||||
ASSERT_TRUE(set.has(entt::entity{42}));
|
||||
ASSERT_EQ(set.get(entt::entity{42}), 0u);
|
||||
ASSERT_EQ(set.index(entt::entity{42}), 0u);
|
||||
|
||||
set.destroy(entt::entity{42});
|
||||
|
||||
@@ -46,7 +46,7 @@ TEST(SparseSet, Functionalities) {
|
||||
set.construct(entt::entity{42});
|
||||
|
||||
ASSERT_FALSE(set.empty());
|
||||
ASSERT_EQ(set.get(entt::entity{42}), 0u);
|
||||
ASSERT_EQ(set.index(entt::entity{42}), 0u);
|
||||
|
||||
ASSERT_TRUE(std::is_move_constructible_v<decltype(set)>);
|
||||
ASSERT_TRUE(std::is_move_assignable_v<decltype(set)>);
|
||||
@@ -56,8 +56,8 @@ TEST(SparseSet, Functionalities) {
|
||||
|
||||
ASSERT_FALSE(set.empty());
|
||||
ASSERT_FALSE(cpy.empty());
|
||||
ASSERT_EQ(set.get(entt::entity{42}), 0u);
|
||||
ASSERT_EQ(cpy.get(entt::entity{42}), 0u);
|
||||
ASSERT_EQ(set.index(entt::entity{42}), 0u);
|
||||
ASSERT_EQ(cpy.index(entt::entity{42}), 0u);
|
||||
|
||||
entt::sparse_set<entt::entity> other{std::move(set)};
|
||||
|
||||
@@ -66,7 +66,7 @@ TEST(SparseSet, Functionalities) {
|
||||
|
||||
ASSERT_TRUE(set.empty());
|
||||
ASSERT_FALSE(other.empty());
|
||||
ASSERT_EQ(other.get(entt::entity{42}), 0u);
|
||||
ASSERT_EQ(other.index(entt::entity{42}), 0u);
|
||||
|
||||
other.reset();
|
||||
|
||||
@@ -134,10 +134,10 @@ TEST(SparseSet, BatchAdd) {
|
||||
|
||||
ASSERT_FALSE(set.empty());
|
||||
ASSERT_EQ(set.size(), 4u);
|
||||
ASSERT_EQ(set.get(entt::entity{12}), 0u);
|
||||
ASSERT_EQ(set.get(entities[0]), 2u);
|
||||
ASSERT_EQ(set.get(entities[1]), 1u);
|
||||
ASSERT_EQ(set.get(entt::entity{24}), 3u);
|
||||
ASSERT_EQ(set.index(entt::entity{12}), 0u);
|
||||
ASSERT_EQ(set.index(entities[0]), 2u);
|
||||
ASSERT_EQ(set.index(entities[1]), 1u);
|
||||
ASSERT_EQ(set.index(entt::entity{24}), 3u);
|
||||
}
|
||||
|
||||
TEST(SparseSet, Iterator) {
|
||||
@@ -212,9 +212,9 @@ TEST(SparseSet, Data) {
|
||||
set.construct(entt::entity{12});
|
||||
set.construct(entt::entity{42});
|
||||
|
||||
ASSERT_EQ(set.get(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(set.get(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(set.get(entt::entity{42}), 2u);
|
||||
ASSERT_EQ(set.index(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(set.index(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(set.index(entt::entity{42}), 2u);
|
||||
|
||||
ASSERT_EQ(*(set.data() + 0u), entt::entity{3});
|
||||
ASSERT_EQ(*(set.data() + 1u), entt::entity{12});
|
||||
@@ -403,15 +403,15 @@ TEST(SparseSet, RespectDisjoint) {
|
||||
lhs.construct(entt::entity{12});
|
||||
lhs.construct(entt::entity{42});
|
||||
|
||||
ASSERT_EQ(lhs.get(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{42}), 2u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{42}), 2u);
|
||||
|
||||
lhs.respect(rhs);
|
||||
|
||||
ASSERT_EQ(std::as_const(lhs).get(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(std::as_const(lhs).get(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(std::as_const(lhs).get(entt::entity{42}), 2u);
|
||||
ASSERT_EQ(std::as_const(lhs).index(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(std::as_const(lhs).index(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(std::as_const(lhs).index(entt::entity{42}), 2u);
|
||||
}
|
||||
|
||||
TEST(SparseSet, RespectOverlap) {
|
||||
@@ -424,15 +424,15 @@ TEST(SparseSet, RespectOverlap) {
|
||||
|
||||
rhs.construct(entt::entity{12});
|
||||
|
||||
ASSERT_EQ(lhs.get(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{42}), 2u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{42}), 2u);
|
||||
|
||||
lhs.respect(rhs);
|
||||
|
||||
ASSERT_EQ(std::as_const(lhs).get(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(std::as_const(lhs).get(entt::entity{12}), 2u);
|
||||
ASSERT_EQ(std::as_const(lhs).get(entt::entity{42}), 1u);
|
||||
ASSERT_EQ(std::as_const(lhs).index(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(std::as_const(lhs).index(entt::entity{12}), 2u);
|
||||
ASSERT_EQ(std::as_const(lhs).index(entt::entity{42}), 1u);
|
||||
}
|
||||
|
||||
TEST(SparseSet, RespectOrdered) {
|
||||
@@ -445,11 +445,11 @@ TEST(SparseSet, RespectOrdered) {
|
||||
lhs.construct(entt::entity{4});
|
||||
lhs.construct(entt::entity{5});
|
||||
|
||||
ASSERT_EQ(lhs.get(entt::entity{1}), 0u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{2}), 1u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{3}), 2u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{4}), 3u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{5}), 4u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{1}), 0u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{2}), 1u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{3}), 2u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{4}), 3u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{5}), 4u);
|
||||
|
||||
rhs.construct(entt::entity{6});
|
||||
rhs.construct(entt::entity{1});
|
||||
@@ -458,21 +458,21 @@ TEST(SparseSet, RespectOrdered) {
|
||||
rhs.construct(entt::entity{4});
|
||||
rhs.construct(entt::entity{5});
|
||||
|
||||
ASSERT_EQ(rhs.get(entt::entity{6}), 0u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{1}), 1u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{2}), 2u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{3}), 3u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{5}), 5u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{6}), 0u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{1}), 1u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{2}), 2u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{3}), 3u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
|
||||
|
||||
rhs.respect(lhs);
|
||||
|
||||
ASSERT_EQ(rhs.get(entt::entity{6}), 0u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{1}), 1u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{2}), 2u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{3}), 3u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{5}), 5u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{6}), 0u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{1}), 1u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{2}), 2u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{3}), 3u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
|
||||
}
|
||||
|
||||
TEST(SparseSet, RespectReverse) {
|
||||
@@ -485,11 +485,11 @@ TEST(SparseSet, RespectReverse) {
|
||||
lhs.construct(entt::entity{4});
|
||||
lhs.construct(entt::entity{5});
|
||||
|
||||
ASSERT_EQ(lhs.get(entt::entity{1}), 0u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{2}), 1u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{3}), 2u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{4}), 3u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{5}), 4u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{1}), 0u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{2}), 1u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{3}), 2u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{4}), 3u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{5}), 4u);
|
||||
|
||||
rhs.construct(entt::entity{5});
|
||||
rhs.construct(entt::entity{4});
|
||||
@@ -498,21 +498,21 @@ TEST(SparseSet, RespectReverse) {
|
||||
rhs.construct(entt::entity{1});
|
||||
rhs.construct(entt::entity{6});
|
||||
|
||||
ASSERT_EQ(rhs.get(entt::entity{5}), 0u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{4}), 1u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{3}), 2u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{2}), 3u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{1}), 4u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{6}), 5u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{5}), 0u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{4}), 1u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{3}), 2u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{2}), 3u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{1}), 4u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{6}), 5u);
|
||||
|
||||
rhs.respect(lhs);
|
||||
|
||||
ASSERT_EQ(rhs.get(entt::entity{6}), 0u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{1}), 1u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{2}), 2u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{3}), 3u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{5}), 5u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{6}), 0u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{1}), 1u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{2}), 2u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{3}), 3u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
|
||||
}
|
||||
|
||||
TEST(SparseSet, RespectUnordered) {
|
||||
@@ -525,11 +525,11 @@ TEST(SparseSet, RespectUnordered) {
|
||||
lhs.construct(entt::entity{4});
|
||||
lhs.construct(entt::entity{5});
|
||||
|
||||
ASSERT_EQ(lhs.get(entt::entity{1}), 0u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{2}), 1u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{3}), 2u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{4}), 3u);
|
||||
ASSERT_EQ(lhs.get(entt::entity{5}), 4u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{1}), 0u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{2}), 1u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{3}), 2u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{4}), 3u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{5}), 4u);
|
||||
|
||||
rhs.construct(entt::entity{3});
|
||||
rhs.construct(entt::entity{2});
|
||||
@@ -538,21 +538,21 @@ TEST(SparseSet, RespectUnordered) {
|
||||
rhs.construct(entt::entity{4});
|
||||
rhs.construct(entt::entity{5});
|
||||
|
||||
ASSERT_EQ(rhs.get(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{2}), 1u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{6}), 2u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{1}), 3u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{5}), 5u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{2}), 1u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{6}), 2u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{1}), 3u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
|
||||
|
||||
rhs.respect(lhs);
|
||||
|
||||
ASSERT_EQ(rhs.get(entt::entity{6}), 0u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{1}), 1u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{2}), 2u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{3}), 3u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.get(entt::entity{5}), 5u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{6}), 0u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{1}), 1u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{2}), 2u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{3}), 3u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{4}), 4u);
|
||||
ASSERT_EQ(rhs.index(entt::entity{5}), 5u);
|
||||
}
|
||||
|
||||
TEST(SparseSet, CanModifyDuringIteration) {
|
||||
|
||||
@@ -697,15 +697,15 @@ TEST(Storage, RespectOverlapEmptyType) {
|
||||
|
||||
rhs.construct(entt::entity{12});
|
||||
|
||||
ASSERT_EQ(lhs.sparse_set<entt::entity>::get(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(lhs.sparse_set<entt::entity>::get(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(lhs.sparse_set<entt::entity>::get(entt::entity{42}), 2u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{12}), 1u);
|
||||
ASSERT_EQ(lhs.index(entt::entity{42}), 2u);
|
||||
|
||||
lhs.respect(rhs);
|
||||
|
||||
ASSERT_EQ(std::as_const(lhs).sparse_set<entt::entity>::get(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(std::as_const(lhs).sparse_set<entt::entity>::get(entt::entity{12}), 2u);
|
||||
ASSERT_EQ(std::as_const(lhs).sparse_set<entt::entity>::get(entt::entity{42}), 1u);
|
||||
ASSERT_EQ(std::as_const(lhs).index(entt::entity{3}), 0u);
|
||||
ASSERT_EQ(std::as_const(lhs).index(entt::entity{12}), 2u);
|
||||
ASSERT_EQ(std::as_const(lhs).index(entt::entity{42}), 1u);
|
||||
}
|
||||
|
||||
TEST(Storage, CanModifyDuringIteration) {
|
||||
|
||||
Reference in New Issue
Block a user