|
|
@@ -333,6 +333,26 @@ public:
|
|
|
return iterator_type{view, unchecked(view), ignore, view->end()};
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Returns the first entity that has the given components, if any.
|
|
|
+ * @return The first entity that has the given components if one exists, the
|
|
|
+ * null entity otherwise.
|
|
|
+ */
|
|
|
+ entity_type front() const {
|
|
|
+ const auto it = begin();
|
|
|
+ return it != end() ? *it : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Returns the last entity that has the given components, if any.
|
|
|
+ * @return The last entity that has the given components if one exists, the
|
|
|
+ * null entity otherwise.
|
|
|
+ */
|
|
|
+ entity_type back() const {
|
|
|
+ const auto it = std::make_reverse_iterator(end());
|
|
|
+ return it != std::make_reverse_iterator(begin()) ? *it : null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @brief Finds an entity.
|
|
|
* @param entt A valid entity identifier.
|
|
|
@@ -654,6 +674,26 @@ public:
|
|
|
return pool->sparse_set<Entity>::end();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Returns the first entity that has the given component, if any.
|
|
|
+ * @return The first entity that has the given component if one exists, the
|
|
|
+ * null entity otherwise.
|
|
|
+ */
|
|
|
+ entity_type front() const {
|
|
|
+ const auto it = begin();
|
|
|
+ return it != end() ? *it : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Returns the last entity that has the given component, if any.
|
|
|
+ * @return The last entity that has the given component if one exists, the
|
|
|
+ * null entity otherwise.
|
|
|
+ */
|
|
|
+ entity_type back() const {
|
|
|
+ const auto it = std::make_reverse_iterator(end());
|
|
|
+ return it != std::make_reverse_iterator(begin()) ? *it : null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @brief Finds an entity.
|
|
|
* @param entt A valid entity identifier.
|