Browse Source

view: removed chunked iteration, no real benefits so far and there is no way to make it consistent across all views in future

Michele Caini 5 years ago
parent
commit
503791d3c0
3 changed files with 0 additions and 179 deletions
  1. 0 7
      docs/md/entity.md
  2. 0 61
      src/entt/entity/view.hpp
  3. 0 111
      test/entt/entity/view.cpp

+ 0 - 7
docs/md/entity.md

@@ -1382,13 +1382,6 @@ iterations.<br/>
 Since they aren't explicitly instantiated, empty components aren't returned in
 Since they aren't explicitly instantiated, empty components aren't returned in
 any case.
 any case.
 
 
-There is also a third method for iterating over entities and components for
-multi component views. It's a chunk based iteration and is made available by
-means of the `chunked` member function.<br/>
-Since this is a particular iteration method with fairly specific purposes, I
-recommend referring to the official documentation for more details and I won't
-further investigate the topic here.
-
 As a side note, in the case of single component views, `get` accepts but doesn't
 As a side note, in the case of single component views, `get` accepts but doesn't
 strictly require a template parameter, since the type is implicitly defined.
 strictly require a template parameter, since the type is implicitly defined.
 However, when the type isn't specified, for consistency with the multi component
 However, when the type isn't specified, for consistency with the multi component

+ 0 - 61
src/entt/entity/view.hpp

@@ -284,30 +284,6 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> final {
         }
         }
     }
     }
 
 
-    template<typename Func, typename... Type>
-    void iterate(Func func, type_list<Type...>) const {
-        const auto last = view->data() + view->size();
-        auto first = view->data();
-
-        while(first != last) {
-            if((std::get<pool_type<Component> *>(pools)->contains(*first) && ...) && !(std::get<const pool_type<Exclude> *>(filter)->contains(*first) || ...)) {
-                const auto base = *(first++);
-                const auto chunk = (std::min)({ (std::get<pool_type<Component> *>(pools)->size() - std::get<pool_type<Component> *>(pools)->index(base))... });
-                size_type length{};
-
-                for(++length;
-                    length < chunk
-                        && ((*(std::get<pool_type<Component> *>(pools)->data() + std::get<pool_type<Component> *>(pools)->index(base) + length) == *first) && ...)
-                        && !(std::get<const pool_type<Exclude> *>(filter)->contains(*first) || ...);
-                    ++length, ++first);
-
-                func(view->data() + view->index(base), (std::get<pool_type<Type> *>(pools)->raw() + std::get<pool_type<Type> *>(pools)->index(base))..., length);
-            } else {
-                ++first;
-            }
-        }
-    }
-
 public:
 public:
     /*! @brief Underlying entity identifier. */
     /*! @brief Underlying entity identifier. */
     using entity_type = Entity;
     using entity_type = Entity;
@@ -547,43 +523,6 @@ public:
         return iterable_view{*this};
         return iterable_view{*this};
     }
     }
 
 
-    /**
-     * @brief Chunked iteration for entities and components
-     *
-     * Chunked iteration tries to spot chunks in the sets of entities and
-     * components and return them one at a time along with their sizes.<br/>
-     * This type of iteration is intended where it's known a priori that the
-     * creation of entities and components takes place in chunk, which is
-     * actually quite common. In this case, various optimizations can be applied
-     * downstream to obtain even better performances from the views.
-     *
-     * The signature of the function must be equivalent to the following:
-     *
-     * @code{.cpp}
-     * void(const entity_type *, Type *..., size_type);
-     * @endcode
-     *
-     * The arguments are as follows:
-     *
-     * * A pointer to the entities belonging to the chunk.
-     * * Pointers to the components associated with the returned entities.
-     * * The length of the chunk.
-     *
-     * Note that the callback can be invoked 0 or more times and no guarantee is
-     * given on the order of the elements.
-     *
-     * @note
-     * Empty types aren't explicitly instantiated and therefore they are never
-     * returned during iterations.
-     *
-     * @tparam Func Type of the function object to invoke.
-     * @param func A valid function object.
-     */
-    template<typename Func>
-    void chunked(Func func) const {
-        iterate(std::move(func), return_type{});
-    }
-
 private:
 private:
     const std::tuple<pool_type<Component> *...> pools;
     const std::tuple<pool_type<Component> *...> pools;
     const std::tuple<const pool_type<Exclude> *...> filter;
     const std::tuple<const pool_type<Exclude> *...> filter;

+ 0 - 111
test/entt/entity/view.cpp

@@ -774,117 +774,6 @@ TEST(MultiComponentView, FrontBack) {
     ASSERT_EQ(view.back(), e0);
     ASSERT_EQ(view.back(), e0);
 }
 }
 
 
-TEST(MultiComponentView, ChunkedEmpty) {
-    entt::registry registry;
-    auto view = registry.view<const entt::id_type, const char>();
-
-    view.chunked([](auto...) { FAIL(); });
-
-    registry.emplace<entt::id_type>(registry.create());
-    registry.emplace<char>(registry.create());
-
-    view.chunked([](auto...) { FAIL(); });
-}
-
-TEST(MultiComponentView, ChunkedContiguous) {
-    entt::registry registry;
-    auto view = registry.view<const entt::id_type, const char>();
-
-    for(auto i = 0; i < 5; ++i) {
-        const auto entity = registry.create();
-        registry.emplace<entt::id_type>(entity, entt::to_integral(entity));
-        registry.emplace<char>(entity);
-    }
-
-    view.chunked([](auto *entity, auto *id, auto *, auto sz) {
-        ASSERT_EQ(sz, 5u);
-
-        for(decltype(sz) i{}; i < sz; ++i) {
-            ASSERT_EQ(entt::to_integral(*(entity + i)), *(id + i));
-        }
-    });
-}
-
-TEST(MultiComponentView, ChunkedSpread) {
-    entt::registry registry;
-    auto view = registry.view<const entt::id_type, const char>();
-
-    registry.emplace<entt::id_type>(registry.create());
-
-    for(auto i = 0; i < 3; ++i) {
-        const auto entity = registry.create();
-        registry.emplace<entt::id_type>(entity, entt::to_integral(entity));
-        registry.emplace<char>(entity);
-    }
-
-    registry.emplace<char>(registry.create());
-
-    for(auto i = 0; i < 3; ++i) {
-        const auto entity = registry.create();
-        registry.emplace<entt::id_type>(entity, entt::to_integral(entity));
-        registry.emplace<char>(entity);
-    }
-
-    registry.emplace<entt::id_type>(registry.create());
-    registry.emplace<entt::id_type>(registry.create());
-    registry.emplace<char>(registry.create());
-
-    view.chunked([](auto *entity, auto *id, auto *, auto sz) {
-        ASSERT_EQ(sz, 3u);
-
-        for(decltype(sz) i{}; i < sz; ++i) {
-            ASSERT_EQ(entt::to_integral(*(entity + i)), *(id + i));
-        }
-    });
-}
-
-TEST(MultiComponentView, ChunkedWithExcludedComponents) {
-    entt::registry registry;
-    auto view = registry.view<const entt::id_type, const char>(entt::exclude<double>);
-
-    registry.emplace<entt::id_type>(registry.create());
-
-    for(auto i = 0; i < 3; ++i) {
-        const auto entity = registry.create();
-        registry.emplace<entt::id_type>(entity, entt::to_integral(entity));
-        registry.emplace<char>(entity);
-    }
-
-    registry.emplace<char>(registry.create());
-
-    for(auto i = 0; i < 2; ++i) {
-        const auto entity = registry.create();
-        registry.emplace<entt::id_type>(entity, entt::to_integral(entity));
-        registry.emplace<char>(entity);
-        registry.emplace<double>(entity);
-    }
-
-    for(auto i = 0; i < 3; ++i) {
-        const auto entity = registry.create();
-        registry.emplace<entt::id_type>(entity, entt::to_integral(entity));
-        registry.emplace<char>(entity);
-    }
-
-    for(auto i = 0; i < 2; ++i) {
-        const auto entity = registry.create();
-        registry.emplace<entt::id_type>(entity, entt::to_integral(entity));
-        registry.emplace<char>(entity);
-        registry.emplace<double>(entity);
-    }
-
-    registry.emplace<entt::id_type>(registry.create());
-    registry.emplace<entt::id_type>(registry.create());
-    registry.emplace<char>(registry.create());
-
-    view.chunked([](auto *entity, auto *id, auto *, auto sz) {
-        ASSERT_EQ(sz, 3u);
-
-        for(decltype(sz) i{}; i < sz; ++i) {
-            ASSERT_EQ(entt::to_integral(*(entity + i)), *(id + i));
-        }
-    });
-}
-
 TEST(MultiComponentView, ExtendedGet) {
 TEST(MultiComponentView, ExtendedGet) {
     using type = decltype(std::declval<entt::registry>().view<int, empty_type, char>().get({}));
     using type = decltype(std::declval<entt::registry>().view<int, empty_type, char>().get({}));
     static_assert(std::tuple_size_v<type> == 2u);
     static_assert(std::tuple_size_v<type> == 2u);