From 216871fe566dcddaf495cfb9ddaae67f45abd988 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Mon, 21 Jun 2021 12:59:44 +0200 Subject: [PATCH] runtime_view: minor changes --- src/entt/entity/runtime_view.hpp | 35 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/entt/entity/runtime_view.hpp b/src/entt/entity/runtime_view.hpp index e093c546c..3a3454af0 100644 --- a/src/entt/entity/runtime_view.hpp +++ b/src/entt/entity/runtime_view.hpp @@ -55,21 +55,10 @@ namespace entt { */ template class basic_runtime_view final { - using underlying_iterator = typename basic_sparse_set::iterator; + using basic_common_type = basic_sparse_set; + using underlying_iterator = typename basic_common_type::iterator; class view_iterator final { - friend class basic_runtime_view; - - view_iterator(const std::vector *> &cpools, const std::vector *> &ignore, underlying_iterator curr) ENTT_NOEXCEPT - : pools{&cpools}, - filter{&ignore}, - it{curr} - { - if(it != (*pools)[0]->end() && !valid()) { - ++(*this); - } - } - [[nodiscard]] bool valid() const { return std::all_of(pools->begin()++, pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); }) && std::none_of(filter->cbegin(), filter->cend(), [entt = *it](const auto *curr) { return curr && curr->contains(entt); }); @@ -84,6 +73,16 @@ class basic_runtime_view final { view_iterator() ENTT_NOEXCEPT = default; + view_iterator(const std::vector &cpools, const std::vector &ignore, underlying_iterator curr) ENTT_NOEXCEPT + : pools{&cpools}, + filter{&ignore}, + it{curr} + { + if(it != (*pools)[0]->end() && !valid()) { + ++(*this); + } + } + view_iterator & operator++() { while(++it != (*pools)[0]->end() && !valid()); return *this; @@ -121,8 +120,8 @@ class basic_runtime_view final { } private: - const std::vector *> *pools; - const std::vector *> *filter; + const std::vector *pools; + const std::vector *filter; underlying_iterator it; }; @@ -149,7 +148,7 @@ public: * @param cpools The storage for the types to iterate. * @param epools The storage for the types used to filter the view. */ - basic_runtime_view(std::vector *> cpools, std::vector *> epools) ENTT_NOEXCEPT + basic_runtime_view(std::vector cpools, std::vector epools) ENTT_NOEXCEPT : pools{std::move(cpools)}, filter{std::move(epools)} { @@ -231,8 +230,8 @@ public: } private: - std::vector *> pools; - std::vector *> filter; + std::vector pools; + std::vector filter; };