|
|
@@ -286,15 +286,39 @@ public:
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @brief Verifies if an entity identifier still refers to a valid entity.
|
|
|
+ * @brief Checks if an entity identifier refers to a valid entity.
|
|
|
* @param entity An entity identifier, either valid or not.
|
|
|
- * @return True if the identifier is still valid, false otherwise.
|
|
|
+ * @return True if the identifier is valid, false otherwise.
|
|
|
*/
|
|
|
bool valid(entity_type entity) const noexcept {
|
|
|
const auto pos = size_type(entity & traits_type::entity_mask);
|
|
|
return (pos < entities.size() && entities[pos] == entity);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Checks if an entity identifier refers to a valid entity.
|
|
|
+ *
|
|
|
+ * Alternative version of `valid`. It accesses the internal data structures
|
|
|
+ * without bounds checking and thus it's both unsafe and risky to use.<br/>
|
|
|
+ * You should not invoke directly this function unless you know exactly what
|
|
|
+ * you are doing. Prefer the `valid` member function instead.
|
|
|
+ *
|
|
|
+ * @warning
|
|
|
+ * Attempting to use an entity that doesn't belong to the registry can
|
|
|
+ * result in undefined behavior.<br/>
|
|
|
+ * An assertion will abort the execution at runtime in debug mode in case of
|
|
|
+ * bounds violation.
|
|
|
+ *
|
|
|
+ * @param entity A valid entity identifier.
|
|
|
+ * @return True if the identifier is valid, false otherwise.
|
|
|
+ */
|
|
|
+ bool fast(entity_type entity) const noexcept {
|
|
|
+ const auto pos = size_type(entity & traits_type::entity_mask);
|
|
|
+ assert(pos < entities.size());
|
|
|
+ // the in-use control bit permits to avoid accessing the direct vector
|
|
|
+ return (entities[pos] == entity);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @brief Returns the version stored along with an entity identifier.
|
|
|
* @param entity An entity identifier, either valid or not.
|