|
|
@@ -74,8 +74,8 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
|
|
|
template<typename Comp>
|
|
|
using component_iterator = decltype(std::declval<pool_type<Comp>>().begin());
|
|
|
|
|
|
- using unchecked_type = std::array<const sparse_set<Entity> *, (sizeof...(Component) - 1)>;
|
|
|
- using filter_type = std::array<const sparse_set<Entity> *, sizeof...(Exclude)>;
|
|
|
+ using unchecked_type = std::array<const basic_sparse_set<Entity> *, (sizeof...(Component) - 1)>;
|
|
|
+ using filter_type = std::array<const basic_sparse_set<Entity> *, sizeof...(Exclude)>;
|
|
|
|
|
|
template<typename It>
|
|
|
class view_iterator final {
|
|
|
@@ -94,8 +94,8 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
|
|
|
}
|
|
|
|
|
|
[[nodiscard]] bool valid() const {
|
|
|
- return std::all_of(unchecked.cbegin(), unchecked.cend(), [entt = *it](const sparse_set<Entity> *curr) { return curr->contains(entt); })
|
|
|
- && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt = *it](const sparse_set<Entity> *cpool) { return cpool->contains(entt); }));
|
|
|
+ return std::all_of(unchecked.cbegin(), unchecked.cend(), [entt = *it](const basic_sparse_set<Entity> *curr) { return curr->contains(entt); })
|
|
|
+ && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt = *it](const basic_sparse_set<Entity> *cpool) { return cpool->contains(entt); }));
|
|
|
}
|
|
|
|
|
|
public:
|
|
|
@@ -154,7 +154,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
|
|
|
class view_proxy {
|
|
|
friend class basic_view<Entity, exclude_t<Exclude...>, Component...>;
|
|
|
|
|
|
- using proxy_view_iterator = view_iterator<typename sparse_set<Entity>::iterator>;
|
|
|
+ using proxy_view_iterator = view_iterator<typename basic_sparse_set<Entity>::iterator>;
|
|
|
|
|
|
class proxy_iterator {
|
|
|
friend class view_proxy;
|
|
|
@@ -237,19 +237,19 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
|
|
|
const std::tuple<pool_type<Component> *...> pools;
|
|
|
};
|
|
|
|
|
|
- basic_view(pool_type<Component> &... component, unpack_as_t<const sparse_set<Entity>, Exclude> &... epool) ENTT_NOEXCEPT
|
|
|
+ basic_view(pool_type<Component> &... component, unpack_as_t<const basic_sparse_set<Entity>, Exclude> &... epool) ENTT_NOEXCEPT
|
|
|
: pools{&component...},
|
|
|
view{candidate()},
|
|
|
filter{&epool...}
|
|
|
{}
|
|
|
|
|
|
- [[nodiscard]] const sparse_set<Entity> * candidate() const ENTT_NOEXCEPT {
|
|
|
- return (std::min)({ static_cast<const sparse_set<Entity> *>(std::get<pool_type<Component> *>(pools))... }, [](const auto *lhs, const auto *rhs) {
|
|
|
+ [[nodiscard]] const basic_sparse_set<Entity> * candidate() const ENTT_NOEXCEPT {
|
|
|
+ return (std::min)({ static_cast<const basic_sparse_set<Entity> *>(std::get<pool_type<Component> *>(pools))... }, [](const auto *lhs, const auto *rhs) {
|
|
|
return lhs->size() < rhs->size();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- [[nodiscard]] unchecked_type unchecked(const sparse_set<Entity> *cpool) const {
|
|
|
+ [[nodiscard]] unchecked_type unchecked(const basic_sparse_set<Entity> *cpool) const {
|
|
|
std::size_t pos{};
|
|
|
unchecked_type other{};
|
|
|
((std::get<pool_type<Component> *>(pools) == cpool ? nullptr : (other[pos] = std::get<pool_type<Component> *>(pools), other[pos++])), ...);
|
|
|
@@ -270,9 +270,9 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
|
|
|
if constexpr(std::disjunction_v<std::is_same<Comp, Type>...>) {
|
|
|
auto it = std::get<pool_type<Comp> *>(pools)->begin();
|
|
|
|
|
|
- for(const auto entt: static_cast<const sparse_set<entity_type> &>(*std::get<pool_type<Comp> *>(pools))) {
|
|
|
+ for(const auto entt: static_cast<const basic_sparse_set<entity_type> &>(*std::get<pool_type<Comp> *>(pools))) {
|
|
|
if(((std::is_same_v<Comp, Component> || std::get<pool_type<Component> *>(pools)->contains(entt)) && ...)
|
|
|
- && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt](const sparse_set<Entity> *cpool) { return cpool->contains(entt); })))
|
|
|
+ && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt](const basic_sparse_set<Entity> *cpool) { return cpool->contains(entt); })))
|
|
|
{
|
|
|
if constexpr(std::is_invocable_v<Func, decltype(get<Type>({}))...>) {
|
|
|
func(get<Comp, Type>(it, std::get<pool_type<Type> *>(pools), entt)...);
|
|
|
@@ -284,9 +284,9 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
|
|
|
++it;
|
|
|
}
|
|
|
} else {
|
|
|
- for(const auto entt: static_cast<const sparse_set<entity_type> &>(*std::get<pool_type<Comp> *>(pools))) {
|
|
|
+ for(const auto entt: static_cast<const basic_sparse_set<entity_type> &>(*std::get<pool_type<Comp> *>(pools))) {
|
|
|
if(((std::is_same_v<Comp, Component> || std::get<pool_type<Component> *>(pools)->contains(entt)) && ...)
|
|
|
- && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt](const sparse_set<Entity> *cpool) { return cpool->contains(entt); })))
|
|
|
+ && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt](const basic_sparse_set<Entity> *cpool) { return cpool->contains(entt); })))
|
|
|
{
|
|
|
if constexpr(std::is_invocable_v<Func, decltype(get<Type>({}))...>) {
|
|
|
func(std::get<pool_type<Type> *>(pools)->get(entt)...);
|
|
|
@@ -305,7 +305,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
|
|
|
|
|
|
while(first != last) {
|
|
|
if((std::get<pool_type<Component> *>(pools)->contains(*first) && ...)
|
|
|
- && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt = *first](const sparse_set<Entity> *cpool) { return cpool->contains(entt); })))
|
|
|
+ && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt = *first](const basic_sparse_set<Entity> *cpool) { return cpool->contains(entt); })))
|
|
|
{
|
|
|
const auto base = *(first++);
|
|
|
const auto chunk = (std::min)({ (std::get<pool_type<Component> *>(pools)->size() - std::get<pool_type<Component> *>(pools)->index(base))... });
|
|
|
@@ -314,7 +314,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
|
|
|
for(++length;
|
|
|
length < chunk
|
|
|
&& ((*(std::get<pool_type<Component> *>(pools)->data() + std::get<pool_type<Component> *>(pools)->index(base) + length) == *first) && ...)
|
|
|
- && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt = *first](const sparse_set<Entity> *cpool) { return cpool->contains(entt); }));
|
|
|
+ && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt = *first](const basic_sparse_set<Entity> *cpool) { return cpool->contains(entt); }));
|
|
|
++length, ++first);
|
|
|
|
|
|
func(view->data() + view->index(base), (std::get<pool_type<Type> *>(pools)->raw() + std::get<pool_type<Type> *>(pools)->index(base))..., length);
|
|
|
@@ -330,9 +330,9 @@ public:
|
|
|
/*! @brief Unsigned integer type. */
|
|
|
using size_type = std::size_t;
|
|
|
/*! @brief Bidirectional iterator type. */
|
|
|
- using iterator = view_iterator<typename sparse_set<entity_type>::iterator>;
|
|
|
+ using iterator = view_iterator<typename basic_sparse_set<entity_type>::iterator>;
|
|
|
/*! @brief Reverse iterator type. */
|
|
|
- using reverse_iterator = view_iterator<typename sparse_set<entity_type>::reverse_iterator>;
|
|
|
+ using reverse_iterator = view_iterator<typename basic_sparse_set<entity_type>::reverse_iterator>;
|
|
|
|
|
|
/**
|
|
|
* @brief Estimates the number of entities iterated by the view.
|
|
|
@@ -566,7 +566,7 @@ public:
|
|
|
*/
|
|
|
template<typename Comp>
|
|
|
[[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
|
|
|
- const sparse_set<entity_type> *cpool = std::get<pool_type<Comp> *>(pools);
|
|
|
+ const basic_sparse_set<entity_type> *cpool = std::get<pool_type<Comp> *>(pools);
|
|
|
iterator first{cpool->begin(), cpool->end(), cpool->begin(), unchecked(cpool), filter};
|
|
|
iterator last{cpool->begin(), cpool->end(), cpool->end(), unchecked(cpool), filter};
|
|
|
return view_proxy{std::move(first), std::move(last), pools};
|
|
|
@@ -613,7 +613,7 @@ public:
|
|
|
|
|
|
private:
|
|
|
const std::tuple<pool_type<Component> *...> pools;
|
|
|
- mutable const sparse_set<entity_type>* view;
|
|
|
+ mutable const basic_sparse_set<entity_type>* view;
|
|
|
filter_type filter;
|
|
|
};
|
|
|
|
|
|
@@ -664,8 +664,8 @@ class basic_view<Entity, exclude_t<>, Component> {
|
|
|
|
|
|
using it_type = std::conditional_t<
|
|
|
is_eto_eligible_v<Component>,
|
|
|
- std::tuple<typename sparse_set<Entity>::iterator>,
|
|
|
- std::tuple<typename sparse_set<Entity>::iterator, decltype(std::declval<pool_type>().begin())>
|
|
|
+ std::tuple<typename basic_sparse_set<Entity>::iterator>,
|
|
|
+ std::tuple<typename basic_sparse_set<Entity>::iterator, decltype(std::declval<pool_type>().begin())>
|
|
|
>;
|
|
|
|
|
|
proxy_iterator(it_type from) ENTT_NOEXCEPT
|
|
|
@@ -713,17 +713,17 @@ class basic_view<Entity, exclude_t<>, Component> {
|
|
|
|
|
|
[[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
|
|
|
if constexpr(is_eto_eligible_v<Component>) {
|
|
|
- return proxy_iterator{std::make_tuple(pool->sparse_set<entity_type>::begin())};
|
|
|
+ return proxy_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::begin())};
|
|
|
} else {
|
|
|
- return proxy_iterator{std::make_tuple(pool->sparse_set<entity_type>::begin(), pool->begin())};
|
|
|
+ return proxy_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::begin(), pool->begin())};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[[nodiscard]] iterator end() const ENTT_NOEXCEPT {
|
|
|
if constexpr(is_eto_eligible_v<Component>) {
|
|
|
- return proxy_iterator{std::make_tuple(pool->sparse_set<entity_type>::end())};
|
|
|
+ return proxy_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::end())};
|
|
|
} else {
|
|
|
- return proxy_iterator{std::make_tuple(pool->sparse_set<entity_type>::end(), pool->end())};
|
|
|
+ return proxy_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::end(), pool->end())};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -743,9 +743,9 @@ public:
|
|
|
/*! @brief Unsigned integer type. */
|
|
|
using size_type = std::size_t;
|
|
|
/*! @brief Random access iterator type. */
|
|
|
- using iterator = typename sparse_set<Entity>::iterator;
|
|
|
+ using iterator = typename basic_sparse_set<Entity>::iterator;
|
|
|
/*! @brief Reversed iterator type. */
|
|
|
- using reverse_iterator = typename sparse_set<Entity>::reverse_iterator;
|
|
|
+ using reverse_iterator = typename basic_sparse_set<Entity>::reverse_iterator;
|
|
|
|
|
|
/**
|
|
|
* @brief Returns the number of entities that have the given component.
|
|
|
@@ -808,7 +808,7 @@ public:
|
|
|
* @return An iterator to the first entity of the view.
|
|
|
*/
|
|
|
[[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
|
|
|
- return pool->sparse_set<Entity>::begin();
|
|
|
+ return pool->basic_sparse_set<Entity>::begin();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -825,7 +825,7 @@ public:
|
|
|
* @return An iterator to the entity following the last entity of the view.
|
|
|
*/
|
|
|
[[nodiscard]] iterator end() const ENTT_NOEXCEPT {
|
|
|
- return pool->sparse_set<Entity>::end();
|
|
|
+ return pool->basic_sparse_set<Entity>::end();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -841,7 +841,7 @@ public:
|
|
|
* @return An iterator to the first entity of the reversed view.
|
|
|
*/
|
|
|
[[nodiscard]] reverse_iterator rbegin() const ENTT_NOEXCEPT {
|
|
|
- return pool->sparse_set<Entity>::rbegin();
|
|
|
+ return pool->basic_sparse_set<Entity>::rbegin();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -860,7 +860,7 @@ public:
|
|
|
* reversed view.
|
|
|
*/
|
|
|
[[nodiscard]] reverse_iterator rend() const ENTT_NOEXCEPT {
|
|
|
- return pool->sparse_set<Entity>::rend();
|
|
|
+ return pool->basic_sparse_set<Entity>::rend();
|
|
|
}
|
|
|
|
|
|
/**
|