EnTT: entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > > Class Template Reference

EnTT 3.16.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
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 | difference_type = std::ptrdiff_t
| Signed 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_type & | handle () 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

  Get | Types of storage observed by the group.
  Exclude | Types 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 303 of file group.hpp.

## ◆ difference_type

template<typename... Get, typename... Exclude>

using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::difference_type = std::ptrdiff_t

Signed integer type.

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 311 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 309 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 305 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 307 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 322 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

  ref | A reference to a group handler.

Definition at line 329 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 449 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 400 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 374 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

  entt | A valid identifier.

Returns
  True if the group contains the given entity, false otherwise.

Definition at line 486 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 567 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 &...);
entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::entity_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

  Func | Type of the function object to invoke.

Parameters

  func | A valid function object.

Definition at line 544 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 389 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 409 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

  entt | A valid identifier.

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

Definition at line 460 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 439 of file group.hpp.

## ◆ get() [1/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

  Index | Indexes of the elements to get.

Parameters

  entt | A valid identifier.

Returns
  The elements assigned to the entity.

Definition at line 509 of file group.hpp.

## ◆ get() [2/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

  Type | Type of the element to get.
  Other | Other types of elements to get.

Parameters

  entt | A valid identifier.

Returns
  The elements assigned to the entity.

Definition at line 498 of file group.hpp.

## ◆ group_id()

template<typename... Get, typename... Exclude>

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 317 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 336 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 477 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

  pos | Position of the element to return.

Returns
  The identifier that occupies the given position.

Definition at line 469 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 420 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 430 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 379 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 365 of file group.hpp.

## ◆ sort() [1/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

  Index | Optional indexes of elements 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.

Definition at line 624 of file group.hpp.

## ◆ sort() [2/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

  Type | Optional type of element to compare.
  Other | Other optional types of elements 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.

Definition at line 606 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

  It | Type of input iterator.

Parameters

  first | An iterator to the first element of the range of entities.
  last | An iterator past the last element of the range of entities.

Definition at line 654 of file group.hpp.

## ◆ storage() [1/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

  Index | Index of the storage to return.

Returns
  The storage for the given index.

Definition at line 356 of file group.hpp.

## ◆ storage() [2/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

  Type | Type of element of which to return the storage.

Returns
  The storage for the given element type.

Definition at line 346 of file group.hpp.

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

- src/entt/entity/group.hpp