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


Public Types | |
| using | base_type = underlying_type |
| Base type. | |
| using | allocator_type = Allocator |
| 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 = typename container_type::pointer |
| Pointer type to contained elements. | |
| using | const_pointer = typename alloc_traits::template rebind_traits< typename alloc_traits::const_pointer >::const_pointer |
| Constant pointer type to contained elements. | |
| using | iterator = internal::storage_iterator< container_type > |
| Random access iterator type. | |
| using | const_iterator = internal::storage_iterator< const container_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. | |
| using | iterable = iterable_adaptor< internal::extended_storage_iterator< typename base_type::iterator, iterator > > |
| Extended iterable storage proxy. | |
| using | const_iterable = iterable_adaptor< internal::extended_storage_iterator< typename base_type::const_iterator, const_iterator > > |
| Constant extended iterable storage proxy. | |
Public Types inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
| using | allocator_type = std::allocator_traits< Allocator >::template rebind_alloc< Entity > |
| Allocator type. | |
| using | entity_type = Entity |
| Underlying entity identifier. | |
| using | version_type = typename entity_traits::version_type |
| Underlying version type. | |
| using | size_type = typename packed_container_type::size_type |
| Unsigned integer type. | |
| using | pointer = typename packed_container_type::const_pointer |
| Pointer type to contained entities. | |
| using | iterator = basic_iterator |
| Random access iterator type. | |
| using | const_iterator = iterator |
| Constant random access iterator type. | |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| Reverse iterator type. | |
| using | const_reverse_iterator = reverse_iterator |
| Constant reverse iterator type. | |
Public Member Functions | |
| basic_storage () | |
| Default constructor. | |
| basic_storage (const allocator_type &allocator) | |
| Constructs an empty storage with a given allocator. More... | |
| basic_storage (basic_storage &&other) | |
| Move constructor. More... | |
| basic_storage (basic_storage &&other, const allocator_type &allocator) | |
| Allocator-extended move constructor. More... | |
| ~basic_storage () override | |
| Default destructor. | |
| basic_storage & | operator= (basic_storage &&other) |
| Move assignment operator. More... | |
| void | swap (basic_storage &other) |
| Exchanges the contents with those of a given storage. More... | |
| constexpr allocator_type | get_allocator () const |
| Returns the associated allocator. More... | |
| void | reserve (const size_type cap) override |
| Increases the capacity of a storage. More... | |
| size_type | capacity () const override |
| Returns the number of elements that a storage has currently allocated space for. More... | |
| void | shrink_to_fit () override |
| 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... | |
| std::tuple< const value_type & > | get_as_tuple (const entity_type entt) const |
| Returns the object assigned to an entity as a tuple. More... | |
| std::tuple< value_type & > | get_as_tuple (const entity_type entt) |
| Returns the object assigned to an entity as a tuple. 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> | |
| value_type & | 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<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... | |
| iterable | each () |
| Returns an iterable object to use to visit a storage. More... | |
| const_iterable | each () const |
| Returns an iterable object to use to visit a storage. More... | |
Public Member Functions inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
| basic_sparse_set () | |
| Default constructor. | |
| basic_sparse_set (const allocator_type &allocator) | |
| Constructs an empty container with a given allocator. More... | |
| basic_sparse_set (deletion_policy pol, const allocator_type &allocator={}) | |
| Constructs an empty container with the given policy and allocator. More... | |
| basic_sparse_set (const type_info &value, deletion_policy pol=deletion_policy::swap_and_pop, const allocator_type &allocator={}) | |
| Constructs an empty container with the given value type, policy and allocator. More... | |
| basic_sparse_set (basic_sparse_set &&other) | |
| Move constructor. More... | |
| basic_sparse_set (basic_sparse_set &&other, const allocator_type &allocator) | |
| Allocator-extended move constructor. More... | |
| virtual | ~basic_sparse_set () |
| Default destructor. | |
| basic_sparse_set & | operator= (basic_sparse_set &&other) |
| Move assignment operator. More... | |
| void | swap (basic_sparse_set &other) |
| Exchanges the contents with those of a given sparse set. More... | |
| constexpr allocator_type | get_allocator () const |
| Returns the associated allocator. More... | |
| deletion_policy | policy () const |
| Returns the deletion policy of a sparse set. More... | |
| virtual void | reserve (const size_type cap) |
| Increases the capacity of a sparse set. More... | |
| 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... | |
| const_iterator | begin () const |
| Returns an iterator to the beginning. More... | |
| const_iterator | cbegin () const |
| Returns an iterator to the beginning. More... | |
| iterator | end () const |
| Returns an iterator to the end. More... | |
| const_iterator | cend () const |
| Returns an iterator to the end. More... | |
| const_reverse_iterator | rbegin () const |
| Returns a reverse iterator to the beginning. More... | |
| const_reverse_iterator | crbegin () const |
| Returns a reverse iterator to the beginning. More... | |
| reverse_iterator | rend () const |
| Returns a reverse iterator to the end. More... | |
| const_reverse_iterator | crend () 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... | |
| version_type | current (const entity_type entt) const |
| Returns the contained version for an identifier. 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... | |
| const void * | get (const entity_type entt) const |
| Returns the element assigned to an entity, if any. More... | |
| void * | get (const entity_type entt) |
| Returns the element assigned to an entity, if any. More... | |
| iterator | emplace (const entity_type entt, const void *value=nullptr) |
| Assigns an entity to a sparse set. More... | |
| void | bump (const entity_type entt) |
| Bump the version number of an entity. More... | |
| iterator | insert (It first, It last) |
| Assigns one or more entities to a sparse set. More... | |
| void | erase (const entity_type entt) |
| Erases an entity from a sparse set. More... | |
| void | erase (It first, It last) |
| Erases entities from a set. More... | |
| bool | remove (const entity_type entt) |
| Removes an entity from a sparse set if it exists. More... | |
| size_type | remove (It first, It last) |
| 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_elements (const entity_type lhs, const entity_type rhs) |
| Swaps two entities in a sparse set. 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 () |
| Clears a sparse set. | |
| const type_info & | type () const |
| Returned value type, if any. More... | |
| virtual void | bind (any) |
| Forwards variables to mixins, if any. | |
Protected Member Functions | |
| void | swap_and_pop (typename underlying_type::basic_iterator first, typename underlying_type::basic_iterator last) override |
| Erases elements from a storage. More... | |
| void | in_place_pop (typename underlying_type::basic_iterator first, typename underlying_type::basic_iterator last) override |
| Erases elements from a storage. More... | |
| underlying_type::basic_iterator | try_emplace ([[maybe_unused]] const Entity entt, const bool force_back, const void *value) override |
| Assigns an entity to a storage. More... | |
Protected Member Functions inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
| virtual basic_iterator | try_emplace (const Entity entt, const bool force_back, const void *=nullptr) |
| Assigns an entity to a sparse set. More... | |
Additional Inherited Members | |
Protected Types inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
| using | basic_iterator = internal::sparse_set_iterator< packed_container_type > |
| Random access iterator type. | |
Basic storage implementation.
Internal data structures arrange elements to maximize performance. There are no guarantees that objects are returned in the insertion order when iterate a storage. Do not make assumption on the order in any case.
| 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 234 of file storage.hpp.
|
inlineexplicit |
Constructs an empty storage with a given allocator.
| allocator | The allocator to use. |
Definition at line 415 of file storage.hpp.
|
inline |
Move constructor.
| other | The instance to move from. |
Definition at line 423 of file storage.hpp.
|
inline |
Allocator-extended move constructor.
| other | The instance to move from. |
| allocator | The allocator to use. |
Definition at line 432 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 539 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 534 of file storage.hpp.
|
inlineoverridevirtual |
Returns the number of elements that a storage has currently allocated space for.
Reimplemented from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > >.
Definition at line 497 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 528 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 554 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 577 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 601 of file storage.hpp.
|
inline |
Returns an iterable object to use to visit a storage.
The iterable object returns a tuple that contains the current entity and a reference to its component.
Definition at line 733 of file storage.hpp.
|
inline |
Returns an iterable object to use to visit a storage.
The iterable object returns a tuple that contains the current entity and a reference to its component.
Definition at line 738 of file storage.hpp.
|
inline |
Assigns an entity to a storage and constructs its object.
| Args | Types of arguments to use to construct the object. |
| entt | A valid identifier. |
| args | Parameters to use to construct an object for the entity. |
Definition at line 661 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 564 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 559 of file storage.hpp.
|
inline |
Returns the object assigned to an entity.
| entt | A valid identifier. |
Definition at line 630 of file storage.hpp.
|
inline |
Returns the object assigned to an entity.
| entt | A valid identifier. |
Definition at line 625 of file storage.hpp.
|
inlineconstexpr |
Returns the associated allocator.
Definition at line 473 of file storage.hpp.
|
inline |
Returns the object assigned to an entity as a tuple.
| entt | A valid identifier. |
Definition at line 644 of file storage.hpp.
|
inline |
Returns the object assigned to an entity as a tuple.
| entt | A valid identifier. |
Definition at line 639 of file storage.hpp.
|
inlineoverrideprotectedvirtual |
Erases elements from a storage.
| first | An iterator to the first element to erase. |
| last | An iterator past the last element to erase. |
Reimplemented from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > >.
Definition at line 349 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 719 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 700 of file storage.hpp.
|
inline |
Move assignment operator.
| other | The instance to move from. |
Definition at line 448 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 identifier. |
| func | Valid function objects. |
Definition at line 679 of file storage.hpp.
|
inline |
Direct access to the array of objects.
Definition at line 516 of file storage.hpp.
|
inline |
Direct access to the array of objects.
Definition at line 511 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 587 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 582 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 611 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 606 of file storage.hpp.
|
inlineoverride |
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 485 of file storage.hpp.
|
inline |
Exchanges the contents with those of a given storage.
| other | Storage to exchange the content with. |
Definition at line 462 of file storage.hpp.
|
inlineoverrideprotectedvirtual |
Erases elements from a storage.
| first | An iterator to the first element to erase. |
| last | An iterator past the last element to erase. |
Reimplemented from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > >.
Definition at line 334 of file storage.hpp.
|
inlineoverrideprotected |
Assigns an entity to a storage.
| entt | A valid identifier. |
| value | Optional opaque value. |
| force_back | Force back insertion. |
Definition at line 363 of file storage.hpp.