OpenLexocad  27.1
entt::storage< Entity, Type > Struct Template Reference

Basic storage implementation. More...

#include <entt.hpp>

Inheritance diagram for entt::storage< Entity, Type >:
entt::basic_storage< Entity, Type, typename > entt::sparse_set< Entity >

Additional Inherited Members

- Public Types inherited from entt::basic_storage< Entity, Type, typename >
using object_type = Type
 Type of the objects associated with the entities. More...
 
using entity_type = Entity
 Underlying entity identifier. More...
 
using size_type = std::size_t
 Unsigned integer type. More...
 
using iterator_type = iterator< false >
 Random access iterator type. More...
 
using const_iterator_type = iterator< true >
 Constant random access iterator type. More...
 
- Public Types inherited from entt::sparse_set< Entity >
using entity_type = Entity
 Underlying entity identifier. More...
 
using size_type = std::size_t
 Unsigned integer type. More...
 
using iterator_type = iterator
 Random access iterator type. More...
 
- Public Member Functions inherited from entt::basic_storage< Entity, Type, typename >
void reserve (const size_type cap)
 Increases the capacity of a storage. More...
 
void shrink_to_fit ()
 Requests the removal of unused capacity. More...
 
const object_typeraw () const ENTT_NOEXCEPT
 Direct access to the array of objects. More...
 
object_typeraw () ENTT_NOEXCEPT
 Direct access to the array of objects. More...
 
const_iterator_type cbegin () const ENTT_NOEXCEPT
 Returns an iterator to the beginning. More...
 
const_iterator_type begin () const ENTT_NOEXCEPT
 Returns an iterator to the beginning. More...
 
iterator_type begin () ENTT_NOEXCEPT
 Returns an iterator to the beginning. More...
 
const_iterator_type cend () const ENTT_NOEXCEPT
 Returns an iterator to the end. More...
 
const_iterator_type end () const ENTT_NOEXCEPT
 Returns an iterator to the end. More...
 
iterator_type end () ENTT_NOEXCEPT
 Returns an iterator to the end. More...
 
const object_typeget (const entity_type entt) const ENTT_NOEXCEPT
 Returns the object associated with an entity. More...
 
object_typeget (const entity_type entt) ENTT_NOEXCEPT
 Returns the object associated with an entity. More...
 
const object_typetry_get (const entity_type entt) const ENTT_NOEXCEPT
 Returns a pointer to the object associated with an entity, if any. More...
 
object_typetry_get (const entity_type entt) ENTT_NOEXCEPT
 Returns a pointer to the object associated with an entity, if any. More...
 
template<typename... Args>
object_typeconstruct (const entity_type entt, Args &&... args)
 Assigns an entity to a storage and constructs its object. More...
 
template<typename It , typename... Args>
iterator_type batch (It first, It last, Args &&... args)
 Assigns one or more entities to a storage and default constructs or copy constructs their objects. More...
 
void destroy (const entity_type entt)
 Removes an entity from a storage and destroys its object. More...
 
void swap (const entity_type lhs, const entity_type rhs) ENTT_NOEXCEPT override
 Swaps entities and objects in the internal packed arrays. More...
 
template<typename Compare , typename Sort = std_sort, typename... Args>
void sort (iterator_type first, iterator_type last, Compare compare, Sort algo=Sort{}, Args &&... args)
 Sort elements according to the given comparison function. More...
 
void reset ()
 Resets a storage. More...
 
- Public Member Functions inherited from entt::sparse_set< Entity >
 sparse_set ()=default
 Default constructor. More...
 
 sparse_set (const sparse_set &other)
 Copy constructor. More...
 
 sparse_set (sparse_set &&)=default
 Default move constructor. More...
 
virtual ~sparse_set () ENTT_NOEXCEPT=default
 Default destructor. More...
 
sparse_setoperator= (const sparse_set &other)
 Copy assignment operator. More...
 
sparse_setoperator= (sparse_set &&)=default
 Default move assignment operator. More...
 
void reserve (const size_type cap)
 Increases the capacity of a sparse set. More...
 
size_type capacity () const ENTT_NOEXCEPT
 Returns the number of elements that a sparse set has currently allocated space for. More...
 
void shrink_to_fit ()
 Requests the removal of unused capacity. More...
 
size_type extent () const ENTT_NOEXCEPT
 Returns the extent of a sparse set. More...
 
size_type size () const ENTT_NOEXCEPT
 Returns the number of elements in a sparse set. More...
 
bool empty () const ENTT_NOEXCEPT
 Checks whether a sparse set is empty. More...
 
const entity_typedata () const ENTT_NOEXCEPT
 Direct access to the internal packed array. More...
 
iterator_type begin () const ENTT_NOEXCEPT
 Returns an iterator to the beginning. More...
 
iterator_type end () const ENTT_NOEXCEPT
 Returns an iterator to the end. More...
 
iterator_type find (const entity_type entt) const ENTT_NOEXCEPT
 Finds an entity. More...
 
bool has (const entity_type entt) const ENTT_NOEXCEPT
 Checks if a sparse set contains an entity. More...
 
size_type index (const entity_type entt) const ENTT_NOEXCEPT
 Returns the position of an entity in a sparse set. More...
 
void construct (const entity_type entt)
 Assigns an entity to a sparse set. More...
 
template<typename It >
void batch (It first, It last)
 Assigns one or more entities to a sparse set. More...
 
void destroy (const entity_type entt)
 Removes an entity from a sparse set. More...
 
template<typename Compare , typename Sort = std_sort, typename... Args>
void sort (iterator_type first, iterator_type last, Compare compare, Sort algo=Sort{}, Args &&... args)
 Sort elements according to the given comparison function. More...
 
template<typename Apply , typename Compare , typename Sort = std_sort, typename... Args>
void arrange (iterator_type first, iterator_type last, Apply apply, Compare compare, Sort algo=Sort{}, Args &&... args)
 Sort elements according to the given comparison function. More...
 
void respect (const sparse_set &other) ENTT_NOEXCEPT
 Sort entities according to their order in another sparse set. More...
 
void reset ()
 Resets a sparse set. More...
 

Detailed Description

template<typename Entity, typename Type>
struct entt::storage< Entity, Type >

Basic storage implementation.

This class is a refinement of a sparse set that associates an object to an entity. The main purpose of this class is to extend sparse sets to store components in a registry. It guarantees fast access both to the elements and to the entities.

Note
Entities and objects have the same order. It's guaranteed both in case of raw access (either to entities or objects) and when using random or input access iterators.
Internal data structures arrange elements to maximize performance. Because of that, there are no guarantees that elements have the expected order when iterate directly the internal packed array (see raw and size member functions for that). Use begin and end instead.
Warning
Empty types aren't explicitly instantiated. Temporary objects are returned in place of the instances of the components and raw access isn't available for them.
See also
sparse_set<Entity>
Template Parameters
EntityA valid entity type (see entt_traits for more details).
TypeType of objects assigned to the entities.

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