|
EnTT
3.8.1
|
Basic storage implementation. More...
#include <storage.hpp>


Public Types | |
| using | allocator_type = typename alloc_traits::allocator_type |
| Allocator type. | |
| using | value_type = Type |
| Type of the objects assigned to entities. | |
| using | entity_type = Entity |
| Underlying entity identifier. | |
| using | size_type = std::size_t |
| Unsigned integer type. | |
| using | pointer = bucket_alloc_pointer |
| Pointer type to contained elements. | |
| using | const_pointer = bucket_alloc_const_pointer |
| Constant pointer type to contained elements. | |
| using | iterator = storage_iterator< value_type > |
| Random access iterator type. | |
| using | const_iterator = storage_iterator< const value_type > |
| Constant random access iterator type. | |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| Reverse iterator type. | |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| Constant reverse iterator type. | |
Public Types inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
| using | allocator_type = typename alloc_traits::allocator_type |
| Allocator type. | |
| using | entity_type = Entity |
| Underlying entity identifier. | |
| using | size_type = std::size_t |
| Unsigned integer type. | |
| using | pointer = alloc_const_pointer |
| Pointer type to contained entities. | |
| using | iterator = sparse_set_iterator |
| Random access iterator type. | |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| Reverse iterator type. | |
Public Member Functions | |
| basic_storage_impl (const allocator_type &alloc={}) | |
| Default constructor. More... | |
| basic_storage_impl (basic_storage_impl &&other) | |
| Move constructor. More... | |
| ~basic_storage_impl () override | |
| Default destructor. | |
| basic_storage_impl & | operator= (basic_storage_impl &&other) |
| Move assignment operator. More... | |
| void | reserve (const size_type cap) |
| Increases the capacity of a storage. More... | |
| size_type | capacity () const |
| Returns the number of elements that a storage has currently allocated space for. More... | |
| void | shrink_to_fit () |
| Requests the removal of unused capacity. | |
| const_pointer | raw () const |
| Direct access to the array of objects. More... | |
| pointer | raw () |
| Direct access to the array of objects. More... | |
| const_iterator | cbegin () const |
| Returns an iterator to the beginning. More... | |
| const_iterator | begin () const |
| Returns an iterator to the beginning. More... | |
| iterator | begin () |
| Returns an iterator to the beginning. More... | |
| const_iterator | cend () const |
| Returns an iterator to the end. More... | |
| const_iterator | end () const |
| Returns an iterator to the end. More... | |
| iterator | end () |
| Returns an iterator to the end. More... | |
| const_reverse_iterator | crbegin () const |
| Returns a reverse iterator to the beginning. More... | |
| const_reverse_iterator | rbegin () const |
| Returns a reverse iterator to the beginning. More... | |
| reverse_iterator | rbegin () |
| Returns a reverse iterator to the beginning. More... | |
| const_reverse_iterator | crend () const |
| Returns a reverse iterator to the end. More... | |
| const_reverse_iterator | rend () const |
| Returns a reverse iterator to the end. More... | |
| reverse_iterator | rend () |
| Returns a reverse iterator to the end. More... | |
| const value_type & | get (const entity_type entt) const |
| Returns the object assigned to an entity. More... | |
| value_type & | get (const entity_type entt) |
| Returns the object assigned to an entity. More... | |
| template<typename... Args> | |
| value_type & | emplace (const entity_type entt, Args &&... args) |
| Assigns an entity to a storage and constructs its object. More... | |
| template<typename... Func> | |
| decltype(auto) | patch (const entity_type entt, Func &&... func) |
| Updates the instance assigned to a given entity in-place. More... | |
| template<typename It > | |
| void | insert (It first, It last, const value_type &value={}) |
| Assigns one or more entities to a storage and constructs their objects from a given instance. More... | |
| template<typename EIt , typename CIt , typename = std::enable_if_t<std::is_same_v<std::decay_t<typename std::iterator_traits<CIt>::value_type>, value_type>>> | |
| void | insert (EIt first, EIt last, CIt from) |
| Assigns one or more entities to a storage and constructs their objects from a given range. More... | |
| template<typename Compare , typename Sort = std_sort, typename... Args> | |
| void | sort_n (const size_type length, Compare compare, Sort algo=Sort{}, Args &&... args) |
| Sort elements according to the given comparison function. More... | |
| template<typename Compare , typename Sort = std_sort, typename... Args> | |
| void | sort (Compare compare, Sort algo=Sort{}, Args &&... args) |
| Sort all elements according to the given comparison function. More... | |
Public Member Functions inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
| basic_sparse_set (deletion_policy pol, const allocator_type &alloc={}) | |
| Constructs an empty container with the given policy and allocator. More... | |
| basic_sparse_set (const allocator_type &alloc={}) | |
| Constructs an empty container with the given allocator. More... | |
| basic_sparse_set (basic_sparse_set &&other) | |
| Move constructor. More... | |
| virtual | ~basic_sparse_set () |
| Default destructor. | |
| basic_sparse_set & | operator= (basic_sparse_set &&other) |
| Move assignment operator. More... | |
| deletion_policy | policy () const |
| Returns the deletion policy of a sparse set. More... | |
| size_type | slot () const |
| Returns the next slot available for insertion. More... | |
| void | reserve (const size_type cap) |
| Increases the capacity of a sparse set. More... | |
| size_type | capacity () const |
| 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. | |
| size_type | extent () const |
| Returns the extent of a sparse set. More... | |
| size_type | size () const |
| Returns the number of elements in a sparse set. More... | |
| bool | empty () const |
| Checks whether a sparse set is empty. More... | |
| pointer | data () const |
| Direct access to the internal packed array. More... | |
| iterator | begin () const |
| Returns an iterator to the beginning. More... | |
| iterator | end () const |
| Returns an iterator to the end. More... | |
| reverse_iterator | rbegin () const |
| Returns a reverse iterator to the beginning. More... | |
| reverse_iterator | rend () const |
| Returns a reverse iterator to the end. More... | |
| iterator | find (const entity_type entt) const |
| Finds an entity. More... | |
| bool | contains (const entity_type entt) const |
| Checks if a sparse set contains an entity. More... | |
| size_type | index (const entity_type entt) const |
| Returns the position of an entity in a sparse set. More... | |
| entity_type | at (const size_type pos) const |
| Returns the entity at specified location, with bounds checking. More... | |
| entity_type | operator[] (const size_type pos) const |
| Returns the entity at specified location, without bounds checking. More... | |
| size_type | emplace_back (const entity_type entt) |
| Appends an entity to a sparse set. More... | |
| size_type | emplace (const entity_type entt) |
| Assigns an entity to a sparse set. More... | |
| void | insert (It first, It last) |
| Assigns one or more entities to a sparse set. More... | |
| void | erase (const entity_type entt, void *ud=nullptr) |
| Erases an entity from a sparse set. More... | |
| void | erase (It first, It last, void *ud=nullptr) |
| Erases entities from a set. More... | |
| bool | remove (const entity_type entt, void *ud=nullptr) |
| Removes an entity from a sparse set if it exists. More... | |
| size_type | remove (It first, It last, void *ud=nullptr) |
| Removes entities from a sparse set if they exist. More... | |
| void | compact () |
| Removes all tombstones from the packed array of a sparse set. | |
| void | swap (const entity_type lhs, const entity_type rhs) |
| Swaps two entities in the internal packed array. More... | |
| void | sort_n (const size_type length, Compare compare, Sort algo=Sort{}, Args &&... args) |
| Sort the first count elements according to the given comparison function. More... | |
| void | sort (Compare compare, Sort algo=Sort{}, Args &&... args) |
| Sort all elements according to the given comparison function. More... | |
| void | respect (const basic_sparse_set &other) |
| Sort entities according to their order in another sparse set. More... | |
| void | clear (void *ud=nullptr) |
| Clears a sparse set. More... | |
Protected Member Functions | |
| void | swap_at (const std::size_t lhs, const std::size_t rhs) final |
| Swaps two entities in the internal packed array. More... | |
| void | move_and_pop (const std::size_t from, const std::size_t to) final |
| Moves an entity in the internal packed array. More... | |
| void | swap_and_pop (const Entity entt, void *ud) override |
| Attempts to erase an entity from the internal packed array. More... | |
| void | in_place_pop (const Entity entt, void *ud) override |
| Attempts to erase an entity from the internal packed array. More... | |
Protected Member Functions inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
| virtual void | swap_at ([[maybe_unused]] const std::size_t lhs,[[maybe_unused]] const std::size_t rhs) |
| Swaps two entities in the internal packed array. More... | |
| virtual void | move_and_pop ([[maybe_unused]] const std::size_t from,[[maybe_unused]] const std::size_t to) |
| Moves an entity in the internal packed array. More... | |
| virtual void | swap_and_pop (const Entity entt,[[maybe_unused]] void *ud) |
| Attempts to erase an entity from the internal packed array. More... | |
| virtual void | in_place_pop (const Entity entt,[[maybe_unused]] void *ud) |
| Attempts to erase an entity from the internal packed array. More... | |
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.
| Entity | A valid entity type (see entt_traits for more details). |
| Type | Type of objects assigned to the entities. |
| Allocator | Type of allocator used to manage memory and elements. |
Definition at line 52 of file storage.hpp.
|
inlineexplicit |
Default constructor.
| alloc | Allocator to use (possibly default-constructed). |
Definition at line 318 of file storage.hpp.
|
inline |
Move constructor.
| other | The instance to move from. |
Definition at line 330 of file storage.hpp.
|
inline |
Returns an iterator to the beginning.
The returned iterator points to the first instance of the internal array. If the storage is empty, the returned iterator will be equal to end().
Definition at line 424 of file storage.hpp.
|
inline |
Returns an iterator to the beginning.
The returned iterator points to the first instance of the internal array. If the storage is empty, the returned iterator will be equal to end().
Definition at line 419 of file storage.hpp.
|
inline |
Returns the number of elements that a storage has currently allocated space for.
Definition at line 382 of file storage.hpp.
|
inline |
Returns an iterator to the beginning.
The returned iterator points to the first instance of the internal array. If the storage is empty, the returned iterator will be equal to end().
Definition at line 413 of file storage.hpp.
|
inline |
Returns an iterator to the end.
The returned iterator points to the element following the last instance of the internal array. Attempting to dereference the returned iterator results in undefined behavior.
Definition at line 439 of file storage.hpp.
|
inline |
Returns a reverse iterator to the beginning.
The returned iterator points to the first instance of the reversed internal array. If the storage is empty, the returned iterator will be equal to rend().
Definition at line 462 of file storage.hpp.
|
inline |
Returns a reverse iterator to the end.
The returned iterator points to the element following the last instance of the reversed internal array. Attempting to dereference the returned iterator results in undefined behavior.
Definition at line 486 of file storage.hpp.
|
inline |
Assigns an entity to a storage and constructs its object.
This version accept both types that can be constructed in place directly and types like aggregates that do not work well with a placement new as performed usually under the hood during an emplace back.
| Args | Types of arguments to use to construct the object. |
| entt | A valid entity identifier. |
| args | Parameters to use to construct an object for the entity. |
Definition at line 537 of file storage.hpp.
|
inline |
Returns an iterator to the end.
The returned iterator points to the element following the last instance of the internal array. Attempting to dereference the returned iterator results in undefined behavior.
Definition at line 449 of file storage.hpp.
|
inline |
Returns an iterator to the end.
The returned iterator points to the element following the last instance of the internal array. Attempting to dereference the returned iterator results in undefined behavior.
Definition at line 444 of file storage.hpp.
|
inline |
Returns the object assigned to an entity.
| entt | A valid entity identifier. |
Definition at line 516 of file storage.hpp.
|
inline |
Returns the object assigned to an entity.
| entt | A valid entity identifier. |
Definition at line 510 of file storage.hpp.
|
inlineoverrideprotected |
Attempts to erase an entity from the internal packed array.
| entt | A valid entity identifier. |
| ud | Optional user data that are forwarded as-is to derived classes. |
Definition at line 285 of file storage.hpp.
|
inline |
Assigns one or more entities to a storage and constructs their objects from a given range.
| EIt | Type of input iterator. |
| CIt | Type of input iterator. |
| first | An iterator to the first element of the range of entities. |
| last | An iterator past the last element of the range of entities. |
| from | An iterator to the first element of the range of objects. |
Definition at line 613 of file storage.hpp.
|
inline |
Assigns one or more entities to a storage and constructs their objects from a given instance.
| It | Type of input iterator. |
| first | An iterator to the first element of the range of entities. |
| last | An iterator past the last element of the range of entities. |
| value | An instance of the object to construct. |
Definition at line 583 of file storage.hpp.
|
inlinefinalprotected |
Moves an entity in the internal packed array.
| from | A valid position of an entity within storage. |
| to | A valid position of an entity within storage. |
Definition at line 265 of file storage.hpp.
|
inline |
Move assignment operator.
| other | The instance to move from. |
Definition at line 348 of file storage.hpp.
|
inline |
Updates the instance assigned to a given entity in-place.
| Func | Types of the function objects to invoke. |
| entt | A valid entity identifier. |
| func | Valid function objects. |
Definition at line 562 of file storage.hpp.
|
inline |
Direct access to the array of objects.
Definition at line 401 of file storage.hpp.
|
inline |
Direct access to the array of objects.
Definition at line 396 of file storage.hpp.
|
inline |
Returns a reverse iterator to the beginning.
The returned iterator points to the first instance of the reversed internal array. If the storage is empty, the returned iterator will be equal to rend().
Definition at line 472 of file storage.hpp.
|
inline |
Returns a reverse iterator to the beginning.
The returned iterator points to the first instance of the reversed internal array. If the storage is empty, the returned iterator will be equal to rend().
Definition at line 467 of file storage.hpp.
|
inline |
Returns a reverse iterator to the end.
The returned iterator points to the element following the last instance of the reversed internal array. Attempting to dereference the returned iterator results in undefined behavior.
Definition at line 496 of file storage.hpp.
|
inline |
Returns a reverse iterator to the end.
The returned iterator points to the element following the last instance of the reversed internal array. Attempting to dereference the returned iterator results in undefined behavior.
Definition at line 491 of file storage.hpp.
|
inline |
Increases the capacity of a storage.
If the new capacity is greater than the current capacity, new storage is allocated, otherwise the method does nothing.
| cap | Desired capacity. |
Definition at line 369 of file storage.hpp.
|
inline |
Sort all elements according to the given comparison function.
| Compare | Type of comparison function object. |
| Sort | Type of sort function object. |
| Args | Types of arguments to forward to the sort function object. |
| 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 690 of file storage.hpp.
|
inline |
Sort elements 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:
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:
| Compare | Type of comparison function object. |
| Sort | Type of sort function object. |
| Args | Types of arguments to forward to the sort function object. |
| length | Number of elements to sort. |
| 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 666 of file storage.hpp.
|
inlineoverrideprotected |
Attempts to erase an entity from the internal packed array.
| entt | A valid entity identifier. |
| ud | Optional user data that are forwarded as-is to derived classes. |
Definition at line 271 of file storage.hpp.
|
inlinefinalprotected |
Swaps two entities in the internal packed array.
| lhs | A valid position of an entity within storage. |
| rhs | A valid position of an entity within storage. |
Definition at line 260 of file storage.hpp.