Browse Source

runtime_view: size -> size_hint, misleading name (breaking change)

Michele Caini 5 years ago
parent
commit
12847593c2
2 changed files with 7 additions and 7 deletions
  1. 3 3
      src/entt/entity/runtime_view.hpp
  2. 4 4
      test/entt/entity/runtime_view.cpp

+ 3 - 3
src/entt/entity/runtime_view.hpp

@@ -154,10 +154,10 @@ public:
     using iterator = view_iterator;
 
     /**
-     * @brief Estimates the number of entities that have the given components.
-     * @return Estimated number of entities that have the given components.
+     * @brief Estimates the number of entities iterated by the view.
+     * @return Estimated number of entities iterated by the view.
      */
-    [[nodiscard]] size_type size() const {
+    [[nodiscard]] size_type size_hint() const {
         return valid() ? pools.front()->size() : size_type{};
     }
 

+ 4 - 4
test/entt/entity/runtime_view.cpp

@@ -36,7 +36,7 @@ TEST(RuntimeView, Functionalities) {
     ASSERT_NO_THROW((++view.begin()));
 
     ASSERT_NE(view.begin(), view.end());
-    ASSERT_EQ(view.size(), decltype(view.size()){1});
+    ASSERT_EQ(view.size_hint(), 1u);
 
     registry.get<char>(e0) = '1';
     registry.get<char>(e1) = '2';
@@ -170,12 +170,12 @@ TEST(RuntimeView, MissingPool) {
     auto view = registry.runtime_view(std::begin(types), std::end(types));
 
     ASSERT_TRUE(view.empty());
-    ASSERT_EQ(view.size(), decltype(view.size()){0});
+    ASSERT_EQ(view.size_hint(), 0u);
 
     registry.emplace<char>(e0);
 
     ASSERT_TRUE(view.empty());
-    ASSERT_EQ(view.size(), decltype(view.size()){0});
+    ASSERT_EQ(view.size_hint(), 0u);
     ASSERT_FALSE(view.contains(e0));
 
     view.each([](auto) { FAIL(); });
@@ -193,7 +193,7 @@ TEST(RuntimeView, EmptyRange) {
     auto view = registry.runtime_view(ptr, ptr);
 
     ASSERT_TRUE(view.empty());
-    ASSERT_EQ(view.size(), decltype(view.size()){0});
+    ASSERT_EQ(view.size_hint(), 0u);
     ASSERT_FALSE(view.contains(e0));
 
     view.each([](auto) { FAIL(); });