|
| basic_group () ENTT_NOEXCEPT |
| Default constructor to use to create empty, invalid groups.
|
|
size_type | size () const ENTT_NOEXCEPT |
| Returns the number of entities that have the given components. More...
|
|
bool | empty () const ENTT_NOEXCEPT |
| Checks whether a group is empty. More...
|
|
template<typename Component > |
Component * | raw () const ENTT_NOEXCEPT |
| Direct access to the list of components of a given pool. More...
|
|
const entity_type * | data () const ENTT_NOEXCEPT |
| Direct access to the list of entities. More...
|
|
iterator | begin () const ENTT_NOEXCEPT |
| Returns an iterator to the first entity of the group. More...
|
|
iterator | end () const ENTT_NOEXCEPT |
| Returns an iterator that is past the last entity of the group. More...
|
|
reverse_iterator | rbegin () const ENTT_NOEXCEPT |
| Returns an iterator to the first entity of the reversed group. More...
|
|
reverse_iterator | rend () const ENTT_NOEXCEPT |
| Returns an iterator that is past the last entity of the reversed group. More...
|
|
entity_type | front () const |
| Returns the first entity of the group, if any. More...
|
|
entity_type | back () const |
| Returns the last entity of the group, if any. More...
|
|
iterator | find (const entity_type entt) const |
| Finds an entity. More...
|
|
entity_type | operator[] (const size_type pos) const |
| Returns the identifier that occupies the given position. More...
|
|
| operator bool () const ENTT_NOEXCEPT |
| Checks if a group is properly initialized. More...
|
|
bool | contains (const entity_type entt) const |
| Checks if a group contains an entity. More...
|
|
template<typename... Component> |
decltype(auto) | get (const entity_type entt) const |
| Returns the components assigned to the given entity. More...
|
|
template<typename Func > |
void | each (Func func) const |
| Iterates entities and components and applies the given function object to them. More...
|
|
iterable_group | each () const ENTT_NOEXCEPT |
| Returns an iterable object to use to visit the group. More...
|
|
template<typename... Component, typename Compare , typename Sort = std_sort, typename... Args> |
void | sort (Compare compare, Sort algo=Sort{}, Args &&... args) const |
| Sort a group according to the given comparison function. More...
|
|
template<typename Entity, typename... Exclude, typename... Get, typename... Owned>
class entt::basic_group< Entity, exclude_t< Exclude... >, get_t< Get... >, Owned... >
Owning group.
Owning groups return all entities and only the entities that have at least the given components. Moreover:
- It's guaranteed that the entity list is tightly packed in memory for fast iterations.
- It's guaranteed that the lists of owned components are tightly packed in memory for even faster iterations and to allow direct access.
- They stay true to the order of the owned components and all instances have the same order in memory.
The more types of components are owned by a group, the faster it is to iterate them.
Important
Iterators aren't invalidated if:
- New instances of the given components are created and assigned to entities.
- The entity currently pointed is modified (as an example, if one of the given components is removed from the entity to which the iterator points).
- The entity currently pointed is destroyed.
In all other cases, modifying the pools iterated by the group in any way invalidates all the iterators and using them results in undefined behavior.
- Note
- Groups share references to the underlying data structures of the registry that generated them. Therefore any change to the entities and to the components made by means of the registry are immediately reflected by all the groups. Moreover, sorting an owning group affects all the instance of the same group (it means that users don't have to call
sort
on each instance to sort all of them because they share the underlying data structure).
- Warning
- Lifetime of a group must not overcome that of the registry that generated it. In any other case, attempting to use a group results in undefined behavior.
- Template Parameters
-
Entity | A valid entity type (see entt_traits for more details). |
Exclude | Types of components used to filter the group. |
Get | Types of components observed by the group. |
Owned | Types of components owned by the group. |
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
Returns an iterator to the first entity of the group.
The returned iterator points to the first entity of the group. If the group is empty, the returned iterator will be equal to end()
.
- Returns
- An iterator to the first entity of the group.
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
Direct access to the list of entities.
The returned pointer is such that range [data(), data() + size())
is always a valid range, even if the container is empty.
- Returns
- A pointer to the array of entities.
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
template<typename Func >
Iterates entities and components and applies the given function object to them.
The function object is invoked for each entity. It is provided with the entity itself and a set of references to non-empty components. The constness of the components is as requested.
The signature of the function must be equivalent to one of the following forms:
- Note
- Empty types aren't explicitly instantiated and therefore they are never returned during iterations.
- Template Parameters
-
Func | Type of the function object to invoke. |
- Parameters
-
func | A valid function object. |
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
Returns an iterable object to use to visit the group.
The iterable object returns tuples that contain the current entity and a set of references to its non-empty components. The constness of the components is as requested.
- Note
- Empty types aren't explicitly instantiated and therefore they are never returned during iterations.
- Returns
- An iterable object to use to visit the group.
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
Returns an iterator that is past the last entity of the group.
The returned iterator points to the entity following the last entity of the group. Attempting to dereference the returned iterator results in undefined behavior.
- Returns
- An iterator to the entity following the last entity of the group.
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
template<typename... Component>
Returns the components assigned to the given entity.
Prefer this function instead of registry::get
during iterations. It has far better performance than its counterpart.
- Warning
- Attempting to use an invalid component type results in a compilation error. Attempting to use an entity that doesn't belong to the group results in undefined behavior.
- Template Parameters
-
Component | Types of components to get. |
- Parameters
-
entt | A valid entity identifier. |
- Returns
- The components assigned to the entity.
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
template<typename Component >
Direct access to the list of components of a given pool.
The returned pointer is such that range [raw<Component>(), raw<Component>() + size())
is always a valid range, even if the container is empty.
- Warning
- This function is only available for owned types.
- Template Parameters
-
Component | Type of component in which one is interested. |
- Returns
- A pointer to the array of components.
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
Returns an iterator to the first entity of the reversed group.
The returned iterator points to the first entity of the reversed group. If the group is empty, the returned iterator will be equal to rend()
.
- Returns
- An iterator to the first entity of the reversed group.
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
Returns an iterator that is past the last entity of the reversed group.
The returned iterator points to the entity following the last entity of the reversed group. Attempting to dereference the returned iterator results in undefined behavior.
- Returns
- An iterator to the entity following the last entity of the reversed group.
template<typename Entity , typename... Exclude, typename... Get, typename... Owned>
template<typename... Component, typename Compare , typename Sort = std_sort, typename... Args>
Sort a group according to the given comparison function.
Sort the group so that iterating it with a couple of iterators returns entities and components in the expected order. See begin
and end
for more details.
The comparison function object must return true
if the first element is less than the second one, false
otherwise. The signature of the comparison function should be equivalent to one of the following:
bool(std::tuple<Component &...>, std::tuple<Component &...>);
bool(const Component &, const Component &);
bool(const Entity, const Entity);
Where Component
are either owned types or not but still such that they are iterated by the group.
Moreover, the comparison function object shall induce a strict weak ordering on the values.
The sort function oject must offer a member function template operator()
that accepts three arguments:
- An iterator to the first element of the range to sort.
- An iterator past the last element of the range to sort.
- A comparison function to use to compare the elements.
- Template Parameters
-
Component | Optional types of components to compare. |
Compare | Type of comparison function object. |
Sort | Type of sort function object. |
Args | Types of arguments to forward to the sort function object. |
- Parameters
-
compare | A valid comparison function object. |
algo | A valid sort function object. |
args | Arguments to forward to the sort function object, if any. |