EnTT  3.7.0
Public Types | Public Member Functions | List of all members
entt::basic_storage< Entity, Type, std::enable_if_t< is_empty_v< Type > > > Class Template Reference

Basic storage implementation. More...

#include <storage.hpp>

Inheritance diagram for entt::basic_storage< Entity, Type, std::enable_if_t< is_empty_v< Type > > >:
Inheritance graph
[legend]
Collaboration diagram for entt::basic_storage< Entity, Type, std::enable_if_t< is_empty_v< Type > > >:
Collaboration graph
[legend]

Public Types

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.
 
- Public Types inherited from entt::basic_sparse_set< Entity >
using entity_type = Entity
 Underlying entity identifier.
 
using size_type = std::size_t
 Unsigned integer type.
 
using iterator = sparse_set_iterator
 Random access iterator type.
 
using reverse_iterator = const entity_type *
 Reverse iterator type.
 

Public Member Functions

void get ([[maybe_unused]] const entity_type entt) const
 Fake get function. More...
 
template<typename... Args>
void emplace (const entity_type entt, Args &&... args)
 Assigns an entity to a storage and constructs its object. More...
 
template<typename... Func>
void patch ([[maybe_unused]] const entity_type entity, 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 &={})
 Assigns one or more entities to a storage. More...
 
- Public Member Functions inherited from entt::basic_sparse_set< Entity >
 basic_sparse_set ()=default
 Default constructor.
 
 basic_sparse_set (basic_sparse_set &&)=default
 Default move constructor.
 
virtual ~basic_sparse_set ()=default
 Default destructor.
 
basic_sparse_setoperator= (basic_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 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.
 
size_type extent () const noexcept
 Returns the extent of a sparse set. More...
 
size_type size () const noexcept
 Returns the number of elements in a sparse set. More...
 
bool empty () const noexcept
 Checks whether a sparse set is empty. More...
 
const entity_typedata () const noexcept
 Direct access to the internal packed array. More...
 
iterator begin () const noexcept
 Returns an iterator to the beginning. More...
 
iterator end () const noexcept
 Returns an iterator to the end. More...
 
reverse_iterator rbegin () const noexcept
 Returns a reverse iterator to the beginning. More...
 
reverse_iterator rend () const noexcept
 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...
 
void emplace (const entity_type entt)
 Assigns an entity to a sparse set. More...
 
template<typename It >
void insert (It first, It last)
 Assigns one or more entities to a sparse set. More...
 
void remove (const entity_type entt, void *ud=nullptr)
 Removes an entity from a sparse set. More...
 
template<typename It >
void remove (It first, It last, void *ud=nullptr)
 Removes multiple entities from a pool. More...
 
void swap (const entity_type lhs, const entity_type rhs)
 Swaps two entities in the internal packed array. More...
 
template<typename Compare , typename Sort = std_sort, typename... Args>
void sort_n (const size_type count, Compare compare, Sort algo=Sort{}, Args &&... args)
 Sort the first count 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...
 
void respect (const basic_sparse_set &other)
 Sort entities according to their order in another sparse set. More...
 
void clear (void *ud=nullptr) noexcept
 Clears a sparse set. More...
 

Additional Inherited Members

- Protected Member Functions inherited from entt::basic_sparse_set< Entity >
virtual void swap_at (const std::size_t, const std::size_t)
 Swaps two entities in the internal packed array.
 
virtual void swap_and_pop (const std::size_t, void *)
 Attempts to remove an entity from the internal packed array.
 

Detailed Description

template<typename Entity, typename Type>
class entt::basic_storage< Entity, Type, std::enable_if_t< is_empty_v< 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. 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.
Warning
Empty types aren't explicitly instantiated. Therefore, many of the functions normally available for non-empty types will not be available for empty ones.
See also
sparse_set<Entity>
Template Parameters
EntityA valid entity type (see entt_traits for more details).
TypeType of objects assigned to the entities.

Definition at line 504 of file storage.hpp.

Member Function Documentation

◆ emplace()

template<typename Entity , typename Type >
template<typename... Args>
void entt::basic_storage< Entity, Type, std::enable_if_t< is_empty_v< Type > > >::emplace ( const entity_type  entt,
Args &&...  args 
)
inline

Assigns an entity to a storage and constructs its object.

Warning
Attempting to use an entity that already belongs to the storage results in undefined behavior.
Template Parameters
ArgsTypes of arguments to use to construct the object.
Parameters
enttA valid entity identifier.
argsParameters to use to construct an object for the entity.

Definition at line 540 of file storage.hpp.

◆ get()

template<typename Entity , typename Type >
void entt::basic_storage< Entity, Type, std::enable_if_t< is_empty_v< Type > > >::get ( [[maybe_unused] ] const entity_type  entt) const
inline

Fake get function.

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

Definition at line 524 of file storage.hpp.

◆ insert()

template<typename Entity , typename Type >
template<typename It >
void entt::basic_storage< Entity, Type, std::enable_if_t< is_empty_v< Type > > >::insert ( It  first,
It  last,
const value_type = {} 
)
inline

Assigns one or more entities to a storage.

Warning
Attempting to assign an entity that already belongs to the storage results in undefined behavior.
Template Parameters
ItType of input iterator.
Parameters
firstAn iterator to the first element of the range of entities.
lastAn iterator past the last element of the range of entities.

Definition at line 569 of file storage.hpp.

◆ patch()

template<typename Entity , typename Type >
template<typename... Func>
void entt::basic_storage< Entity, Type, std::enable_if_t< is_empty_v< Type > > >::patch ( [[maybe_unused] ] const entity_type  entity,
Func &&...  func 
)
inline

Updates the instance assigned to a given entity in-place.

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

Definition at line 552 of file storage.hpp.


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