OpenLexocad
27.0
|
Single component view specialization. More...
#include <entt.hpp>
Public Types | |
using | raw_type = Component |
Type of component iterated by the view. More... | |
using | entity_type = Entity |
Underlying entity identifier. More... | |
using | size_type = std::size_t |
Unsigned integer type. More... | |
using | iterator_type = typename sparse_set< Entity >::iterator_type |
Input iterator type. More... | |
Public Member Functions | |
size_type | size () const ENTT_NOEXCEPT |
Returns the number of entities that have the given component. More... | |
bool | empty () const ENTT_NOEXCEPT |
Checks whether the view is empty. More... | |
raw_type * | raw () const ENTT_NOEXCEPT |
Direct access to the list of components. More... | |
const entity_type * | data () const ENTT_NOEXCEPT |
Direct access to the list of entities. More... | |
iterator_type | begin () const ENTT_NOEXCEPT |
Returns an iterator to the first entity that has the given component. More... | |
iterator_type | end () const ENTT_NOEXCEPT |
Returns an iterator that is past the last entity that has the given component. More... | |
iterator_type | find (const entity_type entt) const ENTT_NOEXCEPT |
Finds an entity. More... | |
entity_type | operator[] (const size_type pos) const ENTT_NOEXCEPT |
Returns the identifier that occupies the given position. More... | |
bool | contains (const entity_type entt) const ENTT_NOEXCEPT |
Checks if a view contains an entity. More... | |
template<typename Comp = Component> | |
decltype(auto) | get (const entity_type entt) const ENTT_NOEXCEPT |
Returns the component 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... | |
template<typename Func > | |
void | less (Func func) const |
Iterates entities and components and applies the given function object to them. More... | |
Friends | |
class | basic_registry< Entity > |
A registry is allowed to create views. More... | |
Single component view specialization.
Single component views are specialized in order to get a boost in terms of performance. This kind of views can access the underlying data structure directly and avoid superfluous checks.
Order of elements during iterations are highly dependent on the order of the underlying data structure. See sparse_set for more details.
Important
Iterators aren't invalidated if:
In all the other cases, modifying the pool of the given component in any way invalidates all the iterators and using them results in undefined behavior.
Entity | A valid entity type (see entt_traits for more details). |
Component | Type of component iterated by the view. |
using entt::basic_view< Entity, exclude_t<>, Component >::entity_type = Entity |
Underlying entity identifier.
using entt::basic_view< Entity, exclude_t<>, Component >::iterator_type = typename sparse_set<Entity>::iterator_type |
Input iterator type.
using entt::basic_view< Entity, exclude_t<>, Component >::raw_type = Component |
Type of component iterated by the view.
using entt::basic_view< Entity, exclude_t<>, Component >::size_type = std::size_t |
Unsigned integer type.
|
inline |
Returns an iterator to the first entity that has the given component.
The returned iterator points to the first entity that has the given component. If the view is empty, the returned iterator will be equal to end()
.
|
inline |
Checks if a view contains an entity.
entt | A valid entity identifier. |
|
inline |
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.
begin
and end
if you want to iterate the view in the expected order.
|
inline |
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 reference to its component. The constness of the component is as requested.
The signature of the function must be equivalent to one of the following forms:
Func | Type of the function object to invoke. |
func | A valid function object. |
|
inline |
Checks whether the view is empty.
|
inline |
Returns an iterator that is past the last entity that has the given component.
The returned iterator points to the entity following the last entity that has the given component. Attempting to dereference the returned iterator results in undefined behavior.
|
inline |
Finds an entity.
entt | A valid entity identifier. |
|
inline |
Returns the component assigned to the given entity.
Prefer this function instead of registry::get
during iterations. It has far better performance than its companion function.
entt | A valid entity identifier. |
|
inline |
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 reference to its component if it's a non-empty one. The constness of the component is as requested.
The signature of the function must be equivalent to one of the following forms in case the component isn't an empty one:
In case the component is an empty one instead, the following forms are accepted:
Func | Type of the function object to invoke. |
func | A valid function object. |
|
inline |
Returns the identifier that occupies the given position.
pos | Position of the element to return. |
|
inline |
Direct access to the list of components.
The returned pointer is such that range [raw(), raw() + size()]
is always a valid range, even if the container is empty.
begin
and end
if you want to iterate the view in the expected order.
|
inline |
Returns the number of entities that have the given component.
|
friend |
A registry is allowed to create views.