EnTT 3.14.0
|
Storage implementation. More...
#include <storage.hpp>
Public Types | |
using | allocator_type = Allocator |
Allocator type. | |
using | base_type = underlying_type |
Base type. | |
using | element_type = Type |
Element type. | |
using | value_type = element_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. | |
using | reverse_iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::reverse_iterator, reverse_iterator>> |
Extended reverse iterable storage proxy. | |
using | const_reverse_iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::const_reverse_iterator, const_reverse_iterator>> |
Constant extended reverse iterable storage proxy. | |
Public Types inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
using | allocator_type |
Allocator type. | |
using | entity_type |
Underlying entity identifier. | |
using | version_type |
Underlying version type. | |
using | size_type |
Unsigned integer type. | |
using | pointer |
Pointer type to contained entities. | |
using | iterator |
Random access iterator type. | |
using | const_iterator |
Constant random access iterator type. | |
using | reverse_iterator |
Reverse iterator type. | |
using | const_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. | |
basic_storage (const basic_storage &)=delete | |
Default copy constructor, deleted on purpose. | |
basic_storage (basic_storage &&other) noexcept | |
Move constructor. | |
basic_storage (basic_storage &&other, const allocator_type &allocator) | |
Allocator-extended move constructor. | |
~basic_storage () override | |
Default destructor. | |
basic_storage & | operator= (const basic_storage &)=delete |
Default copy assignment operator, deleted on purpose. | |
basic_storage & | operator= (basic_storage &&other) noexcept |
Move assignment operator. | |
void | swap (basic_storage &other) noexcept |
Exchanges the contents with those of a given storage. | |
constexpr allocator_type | get_allocator () const noexcept |
Returns the associated allocator. | |
void | reserve (const size_type cap) override |
Increases the capacity of a storage. | |
size_type | capacity () const noexcept override |
Returns the number of elements that a storage has currently allocated space for. | |
void | shrink_to_fit () override |
Requests the removal of unused capacity. | |
const_pointer | raw () const noexcept |
Direct access to the array of objects. | |
pointer | raw () noexcept |
Direct access to the array of objects. | |
const_iterator | cbegin () const noexcept |
Returns an iterator to the beginning. | |
const_iterator | begin () const noexcept |
Returns an iterator to the beginning. | |
iterator | begin () noexcept |
Returns an iterator to the beginning. | |
const_iterator | cend () const noexcept |
Returns an iterator to the end. | |
const_iterator | end () const noexcept |
Returns an iterator to the end. | |
iterator | end () noexcept |
Returns an iterator to the end. | |
const_reverse_iterator | crbegin () const noexcept |
Returns a reverse iterator to the beginning. | |
const_reverse_iterator | rbegin () const noexcept |
Returns a reverse iterator to the beginning. | |
reverse_iterator | rbegin () noexcept |
Returns a reverse iterator to the beginning. | |
const_reverse_iterator | crend () const noexcept |
Returns a reverse iterator to the end. | |
const_reverse_iterator | rend () const noexcept |
Returns a reverse iterator to the end. | |
reverse_iterator | rend () noexcept |
Returns a reverse iterator to the end. | |
const value_type & | get (const entity_type entt) const noexcept |
Returns the object assigned to an entity. | |
value_type & | get (const entity_type entt) noexcept |
Returns the object assigned to an entity. | |
std::tuple< const value_type & > | get_as_tuple (const entity_type entt) const noexcept |
Returns the object assigned to an entity as a tuple. | |
std::tuple< value_type & > | get_as_tuple (const entity_type entt) noexcept |
Returns the object assigned to an entity as a tuple. | |
template<typename... Args> | |
value_type & | emplace (const entity_type entt, Args &&...args) |
Assigns an entity to a storage and constructs its object. | |
template<typename... Func> | |
value_type & | patch (const entity_type entt, Func &&...func) |
Updates the instance assigned to a given entity in-place. | |
template<typename It > | |
iterator | 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. | |
template<typename EIt , typename CIt , typename = std::enable_if_t<std::is_same_v<typename std::iterator_traits<CIt>::value_type, value_type>>> | |
iterator | insert (EIt first, EIt last, CIt from) |
Assigns one or more entities to a storage and constructs their objects from a given range. | |
iterable | each () noexcept |
Returns an iterable object to use to visit a storage. | |
const_iterable | each () const noexcept |
Returns an iterable object to use to visit a storage. | |
reverse_iterable | reach () noexcept |
Returns a reverse iterable object to use to visit a storage. | |
const_reverse_iterable | reach () const noexcept |
Returns a reverse iterable object to use to visit a storage. | |
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. | |
basic_sparse_set (deletion_policy pol, const allocator_type &allocator={}) | |
Constructs an empty container with the given policy and allocator. | |
basic_sparse_set (const type_info &elem, deletion_policy pol=deletion_policy::swap_and_pop, const allocator_type &allocator={}) | |
Constructs an empty container with the given value type, policy and allocator. | |
basic_sparse_set (const basic_sparse_set &)=delete | |
Default copy constructor, deleted on purpose. | |
basic_sparse_set (basic_sparse_set &&other) noexcept | |
Move constructor. | |
basic_sparse_set (basic_sparse_set &&other, const allocator_type &allocator) | |
Allocator-extended move constructor. | |
virtual | ~basic_sparse_set () |
Default destructor. | |
basic_sparse_set & | operator= (const basic_sparse_set &)=delete |
Default copy assignment operator, deleted on purpose. | |
basic_sparse_set & | operator= (basic_sparse_set &&other) noexcept |
Move assignment operator. | |
void | swap (basic_sparse_set &other) noexcept |
Exchanges the contents with those of a given sparse set. | |
constexpr allocator_type | get_allocator () const noexcept |
Returns the associated allocator. | |
deletion_policy | policy () const noexcept |
Returns the deletion policy of a sparse set. | |
size_type | free_list () const noexcept |
Returns data on the free list whose meaning depends on the mode. | |
void | free_list (const size_type value) noexcept |
Sets data on the free list whose meaning depends on the mode. | |
size_type | extent () const noexcept |
Returns the extent of a sparse set. | |
size_type | size () const noexcept |
Returns the number of elements in a sparse set. | |
bool | empty () const noexcept |
Checks whether a sparse set is empty. | |
bool | contiguous () const noexcept |
Checks whether a sparse set is fully packed. | |
pointer | data () const noexcept |
Direct access to the internal packed array. | |
iterator | begin () const noexcept |
Returns an iterator to the beginning. | |
const_iterator | cbegin () const noexcept |
Returns an iterator to the beginning. | |
iterator | end () const noexcept |
Returns an iterator to the end. | |
const_iterator | cend () const noexcept |
Returns an iterator to the end. | |
reverse_iterator | rbegin () const noexcept |
Returns a reverse iterator to the beginning. | |
const_reverse_iterator | crbegin () const noexcept |
Returns a reverse iterator to the beginning. | |
reverse_iterator | rend () const noexcept |
Returns a reverse iterator to the end. | |
const_reverse_iterator | crend () const noexcept |
Returns a reverse iterator to the end. | |
const_iterator | find (const entity_type entt) const noexcept |
Finds an entity. | |
bool | contains (const entity_type entt) const noexcept |
Checks if a sparse set contains an entity. | |
version_type | current (const entity_type entt) const noexcept |
Returns the contained version for an identifier. | |
size_type | index (const entity_type entt) const noexcept |
Returns the position of an entity in a sparse set. | |
entity_type | operator[] (const size_type pos) const noexcept |
Returns the entity at specified location. | |
const void * | value (const entity_type entt) const noexcept |
Returns the element assigned to an entity, if any. | |
void * | value (const entity_type entt) noexcept |
Returns the element assigned to an entity, if any. | |
iterator | push (const entity_type entt, const void *elem=nullptr) |
Assigns an entity to a sparse set. | |
iterator | push (It first, It last) |
Assigns one or more entities to a sparse set. | |
version_type | bump (const entity_type entt) |
Bump the version number of an entity. | |
void | erase (const entity_type entt) |
Erases an entity from a sparse set. | |
void | erase (It first, It last) |
Erases entities from a set. | |
bool | remove (const entity_type entt) |
Removes an entity from a sparse set if it exists. | |
size_type | remove (It first, It last) |
Removes entities from a sparse set if they exist. | |
void | compact () |
Removes all tombstones from a sparse set. | |
void | swap_elements (const entity_type lhs, const entity_type rhs) |
Swaps two entities in a sparse set. | |
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. | |
void | sort (Compare compare, Sort algo=Sort{}, Args &&...args) |
Sort all elements according to the given comparison function. | |
iterator | sort_as (It first, It last) |
Sort entities according to their order in a range. | |
void | clear () |
Clears a sparse set. | |
const type_info & | type () const noexcept |
Returned value type, if any. | |
std::enable_if_t< std::is_same_v< std::remove_const_t< std::remove_reference_t< Type > >, basic_any<> > > | bind (Type &&value) noexcept |
Forwards variables to derived classes, if any. | |
std::enable_if_t<!std::is_same_v< std::remove_const_t< std::remove_reference_t< Type > >, basic_any<> > > | bind (Type &&value) noexcept |
Forwards variables to derived classes, if any. | |
Static Public Attributes | |
static constexpr deletion_policy | storage_policy {traits_type::in_place_delete} |
Storage deletion policy. | |
Protected Member Functions | |
void | pop (underlying_iterator first, underlying_iterator last) override |
Erases entities from a storage. | |
void | pop_all () override |
Erases all entities of a storage. | |
underlying_iterator | try_emplace (const Entity entt, const bool force_back, const void *value) override |
Assigns an entity to a storage. | |
Protected Member Functions inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
void | swap_only (const basic_iterator it) |
Erases an entity from a sparse set. | |
void | swap_and_pop (const basic_iterator it) |
Erases an entity from a sparse set. | |
void | in_place_pop (const basic_iterator it) |
Erases an entity from a sparse set. | |
virtual void | bind_any (any) noexcept |
Forwards variables to derived classes, if any. | |
Additional Inherited Members | |
Protected Types inherited from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > > | |
using | basic_iterator |
Random access iterator type. | |
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.
Type | Element type. |
Entity | A valid entity type. |
Allocator | Type of allocator used to manage memory and elements. |
Definition at line 230 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::allocator_type = Allocator |
Allocator type.
Definition at line 394 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::base_type = underlying_type |
Base type.
Definition at line 396 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::const_iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::const_iterator, const_iterator>> |
Constant extended iterable storage proxy.
Definition at line 420 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::const_iterator = internal::storage_iterator<const container_type> |
Constant random access iterator type.
Definition at line 412 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::const_pointer = typename alloc_traits::template rebind_traits<typename alloc_traits::const_pointer>::const_pointer |
Constant pointer type to contained elements.
Definition at line 408 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::const_reverse_iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::const_reverse_iterator, const_reverse_iterator>> |
Constant extended reverse iterable storage proxy.
Definition at line 424 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Constant reverse iterator type.
Definition at line 416 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::element_type = Type |
Element type.
Definition at line 398 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::entity_type = Entity |
Underlying entity identifier.
Definition at line 402 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::iterator, iterator>> |
Extended iterable storage proxy.
Definition at line 418 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::iterator = internal::storage_iterator<container_type> |
Random access iterator type.
Definition at line 410 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::pointer = typename container_type::pointer |
Pointer type to contained elements.
Definition at line 406 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::reverse_iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::reverse_iterator, reverse_iterator>> |
Extended reverse iterable storage proxy.
Definition at line 422 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::reverse_iterator = std::reverse_iterator<iterator> |
Reverse iterator type.
Definition at line 414 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::size_type = std::size_t |
Unsigned integer type.
Definition at line 404 of file storage.hpp.
using entt::basic_storage< Type, Entity, Allocator, typename >::value_type = element_type |
Type of the objects assigned to entities.
Definition at line 400 of file storage.hpp.
|
inline |
Default constructor.
Definition at line 429 of file storage.hpp.
|
inlineexplicit |
Constructs an empty storage with a given allocator.
allocator | The allocator to use. |
Definition at line 436 of file storage.hpp.
|
inlinenoexcept |
Move constructor.
other | The instance to move from. |
Definition at line 447 of file storage.hpp.
|
inline |
Allocator-extended move constructor.
other | The instance to move from. |
allocator | The allocator to use. |
Definition at line 456 of file storage.hpp.
|
inlineoverride |
Default destructor.
Definition at line 465 of file storage.hpp.
|
inlinenoexcept |
Returns an iterator to the beginning.
If the storage is empty, the returned iterator will be equal to end()
.
Definition at line 560 of file storage.hpp.
|
inlinenoexcept |
Returns an iterator to the beginning.
If the storage is empty, the returned iterator will be equal to end()
.
Definition at line 565 of file storage.hpp.
|
inlineoverridevirtualnoexcept |
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 524 of file storage.hpp.
|
inlinenoexcept |
Returns an iterator to the beginning.
If the storage is empty, the returned iterator will be equal to end()
.
Definition at line 554 of file storage.hpp.
|
inlinenoexcept |
Returns an iterator to the end.
Definition at line 575 of file storage.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the beginning.
If the storage is empty, the returned iterator will be equal to rend()
.
Definition at line 596 of file storage.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the end.
Definition at line 615 of file storage.hpp.
|
inlinenoexcept |
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 element.
Definition at line 758 of file storage.hpp.
|
inlinenoexcept |
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 element.
Definition at line 753 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 675 of file storage.hpp.
|
inlinenoexcept |
Returns an iterator to the end.
Definition at line 580 of file storage.hpp.
|
inlinenoexcept |
Returns an iterator to the end.
Definition at line 585 of file storage.hpp.
|
inlinenoexcept |
Returns the object assigned to an entity.
entt | A valid identifier. |
Definition at line 639 of file storage.hpp.
|
inlinenoexcept |
Returns the object assigned to an entity.
entt | A valid identifier. |
Definition at line 644 of file storage.hpp.
|
inlineconstexprnoexcept |
Returns the associated allocator.
Definition at line 500 of file storage.hpp.
|
inlinenoexcept |
Returns the object assigned to an entity as a tuple.
entt | A valid identifier. |
Definition at line 653 of file storage.hpp.
|
inlinenoexcept |
Returns the object assigned to an entity as a tuple.
entt | A valid identifier. |
Definition at line 658 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 737 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 715 of file storage.hpp.
|
inlinenoexcept |
Move assignment operator.
other | The instance to move from. |
Definition at line 480 of file storage.hpp.
|
delete |
Default copy assignment operator, deleted on purpose.
|
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 693 of file storage.hpp.
|
inlineoverrideprotectedvirtual |
Erases entities from a storage.
first | An iterator to the first element of the range of entities. |
last | An iterator past the last element of the range of entities. |
Reimplemented from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > >.
Definition at line 334 of file storage.hpp.
|
inlineoverrideprotectedvirtual |
Erases all entities of a storage.
Reimplemented from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > >.
Definition at line 353 of file storage.hpp.
|
inlinenoexcept |
Direct access to the array of objects.
Definition at line 538 of file storage.hpp.
|
inlinenoexcept |
Direct access to the array of objects.
Definition at line 543 of file storage.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the beginning.
If the storage is empty, the returned iterator will be equal to rend()
.
Definition at line 601 of file storage.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the beginning.
If the storage is empty, the returned iterator will be equal to rend()
.
Definition at line 606 of file storage.hpp.
|
inlinenoexcept |
Returns a reverse iterable object to use to visit a storage.
Definition at line 774 of file storage.hpp.
|
inlinenoexcept |
Returns a reverse iterable object to use to visit a storage.
Definition at line 769 of file storage.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the end.
Definition at line 620 of file storage.hpp.
|
inlinenoexcept |
Returns a reverse iterator to the end.
Definition at line 625 of file storage.hpp.
|
inlineoverridevirtual |
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. |
Reimplemented from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > >.
Definition at line 512 of file storage.hpp.
|
inlineoverridevirtual |
Requests the removal of unused capacity.
Reimplemented from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > >.
Definition at line 529 of file storage.hpp.
|
inlinenoexcept |
Exchanges the contents with those of a given storage.
other | Storage to exchange the content with. |
Definition at line 490 of file storage.hpp.
|
inlineoverrideprotectedvirtual |
Assigns an entity to a storage.
entt | A valid identifier. |
value | Optional opaque value. |
force_back | Force back insertion. |
Reimplemented from entt::basic_sparse_set< Entity, std::allocator_traits< Allocator >::template rebind_alloc< Entity > >.
Definition at line 376 of file storage.hpp.
|
staticconstexpr |
Storage deletion policy.
Definition at line 426 of file storage.hpp.