EnTT 3.13.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
entt::basic_storage< Entity, Entity, Allocator > Class Template Reference

Swap-only entity storage specialization. More...

#include <storage.hpp>

Inheritance diagram for entt::basic_storage< Entity, Entity, Allocator >:
Inheritance graph
[legend]
Collaboration diagram for entt::basic_storage< Entity, Entity, Allocator >:
Collaboration graph
[legend]

Public Types

using base_type = basic_sparse_set< Entity, Allocator >
 Base type.
 
using value_type = Entity
 Type of the objects assigned to entities.
 
using entity_type = Entity
 Underlying entity identifier.
 
using size_type = std::size_t
 Unsigned integer type.
 
using allocator_type = Allocator
 Allocator type.
 
using iterable = iterable_adaptor< internal::extended_storage_iterator< typename base_type::iterator > >
 Extended iterable storage proxy.
 
using const_iterable = iterable_adaptor< internal::extended_storage_iterator< typename base_type::const_iterator > >
 Constant extended iterable storage proxy.
 
using reverse_iterable = iterable_adaptor< internal::extended_storage_iterator< typename base_type::reverse_iterator > >
 Extended reverse iterable storage proxy.
 
using const_reverse_iterable = iterable_adaptor< internal::extended_storage_iterator< typename base_type::const_reverse_iterator > >
 Constant extended reverse iterable storage proxy.
 
- Public Types inherited from entt::basic_sparse_set< Entity, Allocator >
using traits_type = entt_traits< Entity >
 Entity traits.
 
using entity_type = typename traits_type::value_type
 Underlying entity identifier.
 
using version_type = typename traits_type::version_type
 Underlying version type.
 
using size_type = std::size_t
 Unsigned integer type.
 
using allocator_type = Allocator
 Allocator 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 = std::reverse_iterator< const_iterator >
 Constant reverse iterator type.
 

Public Member Functions

 basic_storage ()
 Default constructor.
 
 basic_storage (const allocator_type &allocator)
 Constructs an empty container with a given allocator.
 
 basic_storage (basic_storage &&other) noexcept
 Move constructor.
 
 basic_storage (basic_storage &&other, const allocator_type &allocator) noexcept
 Allocator-extended move constructor.
 
basic_storageoperator= (basic_storage &&other) noexcept
 Move assignment operator.
 
void get (const entity_type entt) const noexcept
 Returns the object assigned to an entity, that is void.
 
std::tuple get_as_tuple (const entity_type entt) const noexcept
 Returns an empty tuple.
 
entity_type emplace ()
 Creates a new identifier or recycles a destroyed one.
 
entity_type emplace (const entity_type hint)
 Creates a new identifier or recycles a destroyed one.
 
template<typename... Func>
void patch (const entity_type entt, Func &&...func)
 Updates a given identifier.
 
template<typename It >
void insert (It first, It last)
 Assigns each element in a range an identifier.
 
template<typename It >
size_type pack (It first, It last)
 Makes all elements in a range contiguous.
 
size_type in_use () const noexcept
 Returns the number of elements considered still in use.
 
void in_use (const size_type len) noexcept
 Sets the number of elements considered still in use.
 
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, Allocator >
 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 (basic_sparse_set &&other) noexcept
 Move constructor.
 
 basic_sparse_set (basic_sparse_set &&other, const allocator_type &allocator) noexcept
 Allocator-extended move constructor.
 
virtual ~basic_sparse_set ()
 Default destructor.
 
basic_sparse_setoperator= (basic_sparse_set &&other) noexcept
 Move assignment operator.
 
void swap (basic_sparse_set &other)
 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 the head of the free list, if any.
 
void free_list (const size_type len) noexcept
 Sets the head of the free list, if possible.
 
virtual void reserve (const size_type cap)
 Increases the capacity of a sparse set.
 
virtual size_type capacity () const noexcept
 Returns the number of elements that a sparse set has currently allocated space for.
 
virtual void shrink_to_fit ()
 Requests the removal of unused capacity.
 
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.
 
iterator begin (int) const noexcept
 Returns an iterator to the beginning. Useful only in case of swap-only policy.
 
const_iterator cbegin (int) const noexcept
 Returns an iterator to the beginning. Useful only in case of swap-only policy.
 
iterator end (int) const noexcept
 Returns an iterator to the end. Useful only in case of swap-only policy.
 
const_iterator cend (int) const noexcept
 Returns an iterator to the end. Useful only in case of swap-only policy.
 
reverse_iterator rbegin (int) const noexcept
 Returns a reverse iterator to the beginning. Useful only in case of swap-only policy.
 
const_reverse_iterator crbegin (int) const noexcept
 Returns a reverse iterator to the beginning. Useful only in case of swap-only policy.
 
reverse_iterator rend (int) const noexcept
 Returns a reverse iterator to the beginning. Useful only in case of swap-only policy.
 
const_reverse_iterator crend (int) const noexcept
 Returns a reverse iterator to the beginning. Useful only in case of swap-only policy.
 
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 at (const size_type pos) const noexcept
 Returns the entity at specified location, with bounds checking.
 
entity_type operator[] (const size_type pos) const noexcept
 Returns the entity at specified location, without bounds checking.
 
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.
 
template<typename It >
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.
 
template<typename It >
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.
 
template<typename It >
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.
 
template<typename Compare , typename Sort = std_sort, typename... Args>
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.
 
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.
 
template<typename It >
void sort_as (It first, It last)
 Sort entities according to their order in a range.
 
void sort_as (const basic_sparse_set &other)
 Sort entities according to their order in a range.
 
void clear ()
 Clears a sparse set.
 
const type_infotype () const noexcept
 Returned value type, if any.
 
virtual void bind (any) noexcept
 Forwards variables to derived classes, if any.
 

Protected Member Functions

underlying_iterator try_emplace (const Entity hint, const bool, const void *) override
 Assigns an entity to a storage.
 
- Protected Member Functions inherited from entt::basic_sparse_set< Entity, Allocator >
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 pop (basic_iterator first, basic_iterator last)
 Erases entities from a sparse set.
 
virtual void pop_all ()
 Erases all entities of a sparse set.
 
virtual basic_iterator try_emplace (const Entity entt, const bool force_back, const void *=nullptr)
 Assigns an entity to a sparse set.
 

Additional Inherited Members

- Protected Types inherited from entt::basic_sparse_set< Entity, Allocator >
using basic_iterator = internal::sparse_set_iterator< packed_container_type >
 Random access iterator type.
 

Detailed Description

template<typename Entity, typename Allocator>
class entt::basic_storage< Entity, Entity, Allocator >

Swap-only entity storage specialization.

Template Parameters
EntityA valid entity type.
AllocatorType of allocator used to manage memory and elements.

Definition at line 952 of file storage.hpp.

Member Typedef Documentation

◆ allocator_type

template<typename Entity , typename Allocator >
using entt::basic_storage< Entity, Entity, Allocator >::allocator_type = Allocator

Allocator type.

Definition at line 984 of file storage.hpp.

◆ base_type

template<typename Entity , typename Allocator >
using entt::basic_storage< Entity, Entity, Allocator >::base_type = basic_sparse_set<Entity, Allocator>

Base type.

Definition at line 976 of file storage.hpp.

◆ const_iterable

template<typename Entity , typename Allocator >
using entt::basic_storage< Entity, Entity, Allocator >::const_iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::const_iterator> >

Constant extended iterable storage proxy.

Definition at line 988 of file storage.hpp.

◆ const_reverse_iterable

template<typename Entity , typename Allocator >
using entt::basic_storage< Entity, Entity, Allocator >::const_reverse_iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::const_reverse_iterator> >

Constant extended reverse iterable storage proxy.

Definition at line 992 of file storage.hpp.

◆ entity_type

template<typename Entity , typename Allocator >
using entt::basic_storage< Entity, Entity, Allocator >::entity_type = Entity

Underlying entity identifier.

Definition at line 980 of file storage.hpp.

◆ iterable

template<typename Entity , typename Allocator >
using entt::basic_storage< Entity, Entity, Allocator >::iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::iterator> >

Extended iterable storage proxy.

Definition at line 986 of file storage.hpp.

◆ reverse_iterable

template<typename Entity , typename Allocator >
using entt::basic_storage< Entity, Entity, Allocator >::reverse_iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::reverse_iterator> >

Extended reverse iterable storage proxy.

Definition at line 990 of file storage.hpp.

◆ size_type

template<typename Entity , typename Allocator >
using entt::basic_storage< Entity, Entity, Allocator >::size_type = std::size_t

Unsigned integer type.

Definition at line 982 of file storage.hpp.

◆ value_type

template<typename Entity , typename Allocator >
using entt::basic_storage< Entity, Entity, Allocator >::value_type = Entity

Type of the objects assigned to entities.

Definition at line 978 of file storage.hpp.

Constructor & Destructor Documentation

◆ basic_storage() [1/4]

template<typename Entity , typename Allocator >
entt::basic_storage< Entity, Entity, Allocator >::basic_storage ( )
inline

Default constructor.

Definition at line 995 of file storage.hpp.

◆ basic_storage() [2/4]

template<typename Entity , typename Allocator >
entt::basic_storage< Entity, Entity, Allocator >::basic_storage ( const allocator_type allocator)
inlineexplicit

Constructs an empty container with a given allocator.

Parameters
allocatorThe allocator to use.

Definition at line 1003 of file storage.hpp.

◆ basic_storage() [3/4]

template<typename Entity , typename Allocator >
entt::basic_storage< Entity, Entity, Allocator >::basic_storage ( basic_storage< Entity, Entity, Allocator > &&  other)
inlinenoexcept

Move constructor.

Parameters
otherThe instance to move from.

Definition at line 1010 of file storage.hpp.

◆ basic_storage() [4/4]

template<typename Entity , typename Allocator >
entt::basic_storage< Entity, Entity, Allocator >::basic_storage ( basic_storage< Entity, Entity, Allocator > &&  other,
const allocator_type allocator 
)
inlinenoexcept

Allocator-extended move constructor.

Parameters
otherThe instance to move from.
allocatorThe allocator to use.

Definition at line 1018 of file storage.hpp.

Member Function Documentation

◆ each() [1/2]

template<typename Entity , typename Allocator >
const_iterable entt::basic_storage< Entity, Entity, Allocator >::each ( ) const
inlinenoexcept

Returns an iterable object to use to visit a storage.

The iterable object returns a tuple that contains the current entity.

Returns
An iterable object to use to visit the storage.

Definition at line 1167 of file storage.hpp.

◆ each() [2/2]

template<typename Entity , typename Allocator >
iterable entt::basic_storage< Entity, Entity, Allocator >::each ( )
inlinenoexcept

Returns an iterable object to use to visit a storage.

The iterable object returns a tuple that contains the current entity.

Returns
An iterable object to use to visit the storage.

Definition at line 1162 of file storage.hpp.

◆ emplace() [1/2]

template<typename Entity , typename Allocator >
entity_type entt::basic_storage< Entity, Entity, Allocator >::emplace ( )
inline

Creates a new identifier or recycles a destroyed one.

Returns
A valid identifier.

Definition at line 1063 of file storage.hpp.

◆ emplace() [2/2]

template<typename Entity , typename Allocator >
entity_type entt::basic_storage< Entity, Entity, Allocator >::emplace ( const entity_type  hint)
inline

Creates a new identifier or recycles a destroyed one.

If the requested identifier isn't in use, the suggested one is used. Otherwise, a new identifier is returned.

Parameters
hintRequired identifier.
Returns
A valid identifier.

Definition at line 1078 of file storage.hpp.

◆ get()

template<typename Entity , typename Allocator >
void entt::basic_storage< Entity, Entity, Allocator >::get ( const entity_type  entt) const
inlinenoexcept

Returns the object assigned to an entity, that is void.

Warning
Attempting to use an entity that doesn't belong to the storage results in undefined behavior.
Parameters
enttA valid identifier.

Definition at line 1040 of file storage.hpp.

◆ get_as_tuple()

template<typename Entity , typename Allocator >
std::tuple entt::basic_storage< Entity, Entity, Allocator >::get_as_tuple ( const entity_type  entt) const
inlinenoexcept

Returns an empty tuple.

Warning
Attempting to use an entity that doesn't belong to the storage results in undefined behavior.
Parameters
enttA valid identifier.
Returns
Returns an empty tuple.

Definition at line 1054 of file storage.hpp.

◆ in_use() [1/2]

template<typename Entity , typename Allocator >
size_type entt::basic_storage< Entity, Entity, Allocator >::in_use ( ) const
inlinenoexcept

Returns the number of elements considered still in use.

Returns
The number of elements considered still in use.

Definition at line 1143 of file storage.hpp.

◆ in_use() [2/2]

template<typename Entity , typename Allocator >
void entt::basic_storage< Entity, Entity, Allocator >::in_use ( const size_type  len)
inlinenoexcept

Sets the number of elements considered still in use.

Parameters
lenThe number of elements considered still in use.

Definition at line 1151 of file storage.hpp.

◆ insert()

template<typename Entity , typename Allocator >
template<typename It >
void entt::basic_storage< Entity, Entity, Allocator >::insert ( It  first,
It  last 
)
inline

Assigns each element in a range an identifier.

Template Parameters
ItType of mutable forward iterator.
Parameters
firstAn iterator to the first element of the range to generate.
lastAn iterator past the last element of the range to generate.

Definition at line 1116 of file storage.hpp.

◆ operator=()

template<typename Entity , typename Allocator >
basic_storage & entt::basic_storage< Entity, Entity, Allocator >::operator= ( basic_storage< Entity, Entity, Allocator > &&  other)
inlinenoexcept

Move assignment operator.

Parameters
otherThe instance to move from.
Returns
This storage.

Definition at line 1026 of file storage.hpp.

◆ pack()

template<typename Entity , typename Allocator >
template<typename It >
size_type entt::basic_storage< Entity, Entity, Allocator >::pack ( It  first,
It  last 
)
inline

Makes all elements in a range contiguous.

Template Parameters
ItType of forward iterator.
Parameters
firstAn iterator to the first element of the range to pack.
lastAn iterator past the last element of the range to pack.
Returns
The number of elements within the newly created range.

Definition at line 1134 of file storage.hpp.

◆ patch()

template<typename Entity , typename Allocator >
template<typename... Func>
void entt::basic_storage< Entity, Entity, Allocator >::patch ( const entity_type  entt,
Func &&...  func 
)
inline

Updates a given identifier.

Template Parameters
FuncTypes of the function objects to invoke.
Parameters
enttA valid identifier.
funcValid function objects.

Definition at line 1104 of file storage.hpp.

◆ reach() [1/2]

template<typename Entity , typename Allocator >
const_reverse_iterable entt::basic_storage< Entity, Entity, Allocator >::reach ( ) const
inlinenoexcept

Returns a reverse iterable object to use to visit a storage.

See also
each
Returns
A reverse iterable object to use to visit the storage.

Definition at line 1183 of file storage.hpp.

◆ reach() [2/2]

template<typename Entity , typename Allocator >
reverse_iterable entt::basic_storage< Entity, Entity, Allocator >::reach ( )
inlinenoexcept

Returns a reverse iterable object to use to visit a storage.

See also
each
Returns
A reverse iterable object to use to visit the storage.

Definition at line 1178 of file storage.hpp.

◆ try_emplace()

template<typename Entity , typename Allocator >
underlying_iterator entt::basic_storage< Entity, Entity, Allocator >::try_emplace ( const Entity  hint,
const bool  ,
const void *   
)
inlineoverrideprotectedvirtual

Assigns an entity to a storage.

Parameters
hintA valid identifier.
Returns
Iterator pointing to the emplaced element.

Reimplemented from entt::basic_sparse_set< Entity, Allocator >.

Definition at line 970 of file storage.hpp.


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