view: stable multi type view ::find/::back/::front functions
This commit is contained in:
@@ -423,11 +423,15 @@ public:
|
||||
* otherwise.
|
||||
*/
|
||||
[[nodiscard]] entity_type back() const noexcept {
|
||||
if(view) {
|
||||
auto it = view->rbegin();
|
||||
for(const auto last = view->rend(); it != last && !contains(*it); ++it) {}
|
||||
return it == view->rend() ? null : *it;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Finds an entity.
|
||||
* @param entt A valid identifier.
|
||||
|
||||
@@ -632,6 +632,10 @@ TEST(MultiComponentView, InvalidView) {
|
||||
|
||||
ASSERT_EQ(view.size_hint(), 0u);
|
||||
ASSERT_FALSE(view.contains(entt::null));
|
||||
ASSERT_EQ(view.find(entt::null), view.end());
|
||||
|
||||
ASSERT_EQ(view.front(), static_cast<entt::entity>(entt::null));
|
||||
ASSERT_EQ(view.back(), static_cast<entt::entity>(entt::null));
|
||||
|
||||
ASSERT_EQ(view.begin(), typename decltype(view)::iterator{});
|
||||
ASSERT_EQ(view.begin(), view.end());
|
||||
|
||||
Reference in New Issue
Block a user