EnTT 3.14.0
Loading...
Searching...
No Matches
entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > > Class Template Reference

Non-owning group. More...

#include <group.hpp>

Public Types

using entity_type = underlying_type
 Underlying entity identifier.
 
using size_type = std::size_t
 Unsigned integer type.
 
using common_type = base_type
 Common type among all storage types.
 
using iterator = typename common_type::iterator
 Random access iterator type.
 
using reverse_iterator = typename common_type::reverse_iterator
 Reverse iterator type.
 
using iterable = iterable_adaptor<internal::extended_group_iterator<iterator, owned_t<>, get_t<Get...>>>
 Iterable group type.
 
using handler = internal::group_handler<common_type, 0u, sizeof...(Get), sizeof...(Exclude)>
 Group handler type.
 

Public Member Functions

 basic_group () noexcept
 Default constructor to use to create empty, invalid groups.
 
 basic_group (handler &ref) noexcept
 Constructs a group from a set of storage classes.
 
const common_typehandle () const noexcept
 Returns the leading storage of a group.
 
template<typename Type >
auto * storage () const noexcept
 Returns the storage for a given element type, if any.
 
template<std::size_t Index>
auto * storage () const noexcept
 Returns the storage for a given index, if any.
 
size_type size () const noexcept
 Returns the number of entities that are part of the group.
 
size_type capacity () const noexcept
 Returns the number of elements that a group has currently allocated space for.
 
void shrink_to_fit ()
 Requests the removal of unused capacity.
 
bool empty () const noexcept
 Checks whether a group is empty.
 
iterator begin () const noexcept
 Returns an iterator to the first entity of the group.
 
iterator end () const noexcept
 Returns an iterator that is past the last entity of the group.
 
reverse_iterator rbegin () const noexcept
 Returns an iterator to the first entity of the reversed group.
 
reverse_iterator rend () const noexcept
 Returns an iterator that is past the last entity of the reversed group.
 
entity_type front () const noexcept
 Returns the first entity of the group, if any.
 
entity_type back () const noexcept
 Returns the last entity of the group, if any.
 
iterator find (const entity_type entt) const noexcept
 Finds an entity.
 
entity_type operator[] (const size_type pos) const
 Returns the identifier that occupies the given position.
 
 operator bool () const noexcept
 Checks if a group is properly initialized.
 
bool contains (const entity_type entt) const noexcept
 Checks if a group contains an entity.
 
template<typename Type , typename... Other>
decltype(auto) get (const entity_type entt) const
 Returns the elements assigned to the given entity.
 
template<std::size_t... Index>
decltype(auto) get (const entity_type entt) const
 Returns the elements assigned to the given entity.
 
template<typename Func >
void each (Func func) const
 Iterates entities and elements and applies the given function object to them.
 
iterable each () const noexcept
 Returns an iterable object to use to visit a group.
 
template<typename Type , typename... Other, typename Compare , typename Sort = std_sort, typename... Args>
void sort (Compare compare, Sort algo=Sort{}, Args &&...args)
 Sort a group according to the given comparison function.
 
template<std::size_t... Index, typename Compare , typename Sort = std_sort, typename... Args>
void sort (Compare compare, Sort algo=Sort{}, Args &&...args)
 Sort a group according to the given comparison function.
 
template<typename It >
void sort_as (It first, It last) const
 Sort entities according to their order in a range.
 

Static Public Member Functions

static id_type group_id () noexcept
 Group opaque identifier.
 

Detailed Description

template<typename... Get, typename... Exclude>
class entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >

Non-owning group.

A non-owning group returns all entities and only the entities that are at least in the given storage. Moreover, it's guaranteed that the entity list is tightly packed in memory for fast iterations.

Important

Iterators aren't invalidated if:

  • New elements are added to the storage.
  • The entity currently pointed is modified (for example, elements are added or removed from it).
  • The entity currently pointed is destroyed.

In all other cases, modifying the pools iterated by the group in any way invalidates all the iterators.

Template Parameters
GetTypes of storage observed by the group.
ExcludeTypes of storage used to filter the group.

Definition at line 282 of file group.hpp.

Member Typedef Documentation

◆ common_type

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::common_type = base_type

Common type among all storage types.

Definition at line 301 of file group.hpp.

◆ entity_type

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::entity_type = underlying_type

Underlying entity identifier.

Definition at line 297 of file group.hpp.

◆ handler

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::handler = internal::group_handler<common_type, 0u, sizeof...(Get), sizeof...(Exclude)>

Group handler type.

Definition at line 309 of file group.hpp.

◆ iterable

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::iterable = iterable_adaptor<internal::extended_group_iterator<iterator, owned_t<>, get_t<Get...>>>

Iterable group type.

Definition at line 307 of file group.hpp.

◆ iterator

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::iterator = typename common_type::iterator

Random access iterator type.

Definition at line 303 of file group.hpp.

◆ reverse_iterator

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::reverse_iterator = typename common_type::reverse_iterator

Reverse iterator type.

Definition at line 305 of file group.hpp.

◆ size_type

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::size_type = std::size_t

Unsigned integer type.

Definition at line 299 of file group.hpp.

Constructor & Destructor Documentation

◆ basic_group() [1/2]

template<typename... Get, typename... Exclude>
entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::basic_group ( )
inlinenoexcept

Default constructor to use to create empty, invalid groups.

Definition at line 320 of file group.hpp.

◆ basic_group() [2/2]

template<typename... Get, typename... Exclude>
entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::basic_group ( handler & ref)
inlinenoexcept

Constructs a group from a set of storage classes.

Parameters
refA reference to a group handler.

Definition at line 327 of file group.hpp.

Member Function Documentation

◆ back()

template<typename... Get, typename... Exclude>
entity_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::back ( ) const
inlinenodiscardnoexcept

Returns the last entity of the group, if any.

Returns
The last entity of the group if one exists, the null entity otherwise.

Definition at line 447 of file group.hpp.

◆ begin()

template<typename... Get, typename... Exclude>
iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::begin ( ) const
inlinenodiscardnoexcept

Returns an iterator 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.

Definition at line 398 of file group.hpp.

◆ capacity()

template<typename... Get, typename... Exclude>
size_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::capacity ( ) const
inlinenodiscardnoexcept

Returns the number of elements that a group has currently allocated space for.

Returns
Capacity of the group.

Definition at line 372 of file group.hpp.

◆ contains()

template<typename... Get, typename... Exclude>
bool entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::contains ( const entity_type entt) const
inlinenodiscardnoexcept

Checks if a group contains an entity.

Parameters
enttA valid identifier.
Returns
True if the group contains the given entity, false otherwise.

Definition at line 484 of file group.hpp.

◆ each() [1/2]

template<typename... Get, typename... Exclude>
iterable entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::each ( ) const
inlinenodiscardnoexcept

Returns an iterable object to use to visit a group.

The iterable object returns tuples that contain the current entity and a set of references to its non-empty elements. The constness of the elements 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.

Definition at line 565 of file group.hpp.

◆ each() [2/2]

template<typename... Get, typename... Exclude>
template<typename Func >
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::each ( Func func) const
inline

Iterates entities and elements 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 elements. The constness of the elements is as requested.
The signature of the function must be equivalent to one of the following forms:

void(const entity_type, Type &...);
void(Type &...);
underlying_type entity_type
Underlying entity identifier.
Definition group.hpp:297
Note
Empty types aren't explicitly instantiated and therefore they are never returned during iterations.
Template Parameters
FuncType of the function object to invoke.
Parameters
funcA valid function object.

Definition at line 542 of file group.hpp.

◆ empty()

template<typename... Get, typename... Exclude>
bool entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::empty ( ) const
inlinenodiscardnoexcept

Checks whether a group is empty.

Returns
True if the group is empty, false otherwise.

Definition at line 387 of file group.hpp.

◆ end()

template<typename... Get, typename... Exclude>
iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::end ( ) const
inlinenodiscardnoexcept

Returns an iterator that is past the last entity of the group.

Returns
An iterator to the entity following the last entity of the group.

Definition at line 407 of file group.hpp.

◆ find()

template<typename... Get, typename... Exclude>
iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::find ( const entity_type entt) const
inlinenodiscardnoexcept

Finds an entity.

Parameters
enttA valid identifier.
Returns
An iterator to the given entity if it's found, past the end iterator otherwise.

Definition at line 458 of file group.hpp.

◆ front()

template<typename... Get, typename... Exclude>
entity_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::front ( ) const
inlinenodiscardnoexcept

Returns the first entity of the group, if any.

Returns
The first entity of the group if one exists, the null entity otherwise.

Definition at line 437 of file group.hpp.

◆ get() [1/2]

template<typename... Get, typename... Exclude>
template<typename Type , typename... Other>
decltype(auto) entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::get ( const entity_type entt) const
inlinenodiscard

Returns the elements assigned to the given entity.

Template Parameters
TypeType of the element to get.
OtherOther types of elements to get.
Parameters
enttA valid identifier.
Returns
The elements assigned to the entity.

Definition at line 496 of file group.hpp.

◆ get() [2/2]

template<typename... Get, typename... Exclude>
template<std::size_t... Index>
decltype(auto) entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::get ( const entity_type entt) const
inlinenodiscard

Returns the elements assigned to the given entity.

Template Parameters
IndexIndexes of the elements to get.
Parameters
enttA valid identifier.
Returns
The elements assigned to the entity.

Definition at line 507 of file group.hpp.

◆ group_id()

template<typename... Get, typename... Exclude>
static id_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::group_id ( )
inlinestaticnoexcept

Group opaque identifier.

Returns
Group opaque identifier.

Definition at line 315 of file group.hpp.

◆ handle()

template<typename... Get, typename... Exclude>
const common_type & entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::handle ( ) const
inlinenodiscardnoexcept

Returns the leading storage of a group.

Returns
The leading storage of the group.

Definition at line 334 of file group.hpp.

◆ operator bool()

template<typename... Get, typename... Exclude>
entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::operator bool ( ) const
inlineexplicitnodiscardnoexcept

Checks if a group is properly initialized.

Returns
True if the group is properly initialized, false otherwise.

Definition at line 475 of file group.hpp.

◆ operator[]()

template<typename... Get, typename... Exclude>
entity_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::operator[] ( const size_type pos) const
inlinenodiscard

Returns the identifier that occupies the given position.

Parameters
posPosition of the element to return.
Returns
The identifier that occupies the given position.

Definition at line 467 of file group.hpp.

◆ rbegin()

template<typename... Get, typename... Exclude>
reverse_iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::rbegin ( ) const
inlinenodiscardnoexcept

Returns an iterator 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.

Definition at line 418 of file group.hpp.

◆ rend()

template<typename... Get, typename... Exclude>
reverse_iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::rend ( ) const
inlinenodiscardnoexcept

Returns an iterator that is past the last entity of the reversed group.

Returns
An iterator to the entity following the last entity of the reversed group.

Definition at line 428 of file group.hpp.

◆ shrink_to_fit()

template<typename... Get, typename... Exclude>
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::shrink_to_fit ( )
inline

Requests the removal of unused capacity.

Definition at line 377 of file group.hpp.

◆ size()

template<typename... Get, typename... Exclude>
size_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::size ( ) const
inlinenodiscardnoexcept

Returns the number of entities that are part of the group.

Returns
Number of entities that are part of the group.

Definition at line 363 of file group.hpp.

◆ sort() [1/2]

template<typename... Get, typename... Exclude>
template<typename Type , typename... Other, typename Compare , typename Sort = std_sort, typename... Args>
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::sort ( Compare compare,
Sort algo = Sort{},
Args &&... args )
inline

Sort a group according to the given comparison function.

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<Type &...>, std::tuple<Type &...>);
bool(const Type &..., const Type &...);
bool(const Entity, const Entity);

Where Type are 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 object 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
TypeOptional type of element to compare.
OtherOther optional types of elements to compare.
CompareType of comparison function object.
SortType of sort function object.
ArgsTypes of arguments to forward to the sort function object.
Parameters
compareA valid comparison function object.
algoA valid sort function object.
argsArguments to forward to the sort function object, if any.

Definition at line 604 of file group.hpp.

◆ sort() [2/2]

template<typename... Get, typename... Exclude>
template<std::size_t... Index, typename Compare , typename Sort = std_sort, typename... Args>
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::sort ( Compare compare,
Sort algo = Sort{},
Args &&... args )
inline

Sort a group according to the given comparison function.

See also
sort
Template Parameters
IndexOptional indexes of elements to compare.
CompareType of comparison function object.
SortType of sort function object.
ArgsTypes of arguments to forward to the sort function object.
Parameters
compareA valid comparison function object.
algoA valid sort function object.
argsArguments to forward to the sort function object, if any.

Definition at line 622 of file group.hpp.

◆ sort_as()

template<typename... Get, typename... Exclude>
template<typename It >
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::sort_as ( It first,
It last ) const
inline

Sort entities according to their order in a range.

The shared pool of entities and thus its order is affected by the changes to each and every pool that it tracks.

Template Parameters
ItType of input iterator.
Parameters
firstAn iterator to the first element of the range of entities.
lastAn iterator past the last element of the range of entities.

Definition at line 652 of file group.hpp.

◆ storage() [1/2]

template<typename... Get, typename... Exclude>
template<typename Type >
auto * entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::storage ( ) const
inlinenodiscardnoexcept

Returns the storage for a given element type, if any.

Template Parameters
TypeType of element of which to return the storage.
Returns
The storage for the given element type.

Definition at line 344 of file group.hpp.

◆ storage() [2/2]

template<typename... Get, typename... Exclude>
template<std::size_t Index>
auto * entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::storage ( ) const
inlinenodiscardnoexcept

Returns the storage for a given index, if any.

Template Parameters
IndexIndex of the storage to return.
Returns
The storage for the given index.

Definition at line 354 of file group.hpp.


The documentation for this class was generated from the following file: