SparseArray class, used to store components in a sparse way.
More...
#include <SparseArray.hpp>
|
using | ConstIterator = typename Container::const_iterator |
|
using | ConstReferenceType = const ValueType & |
|
using | Container = std::vector< ValueType > |
|
using | Iterator = typename Container::iterator |
|
using | ReferenceType = ValueType & |
|
using | SizeType = typename Container::size_type |
|
using | ValueType = std::shared_ptr< std::optional< Component > > |
|
|
Container | _data |
| Container of the components.
|
|
template<typename Component>
class uranus::ecs::SparseArray< Component >
SparseArray class, used to store components in a sparse way.
- Template Parameters
-
Component | Type of the component to store |
◆ SparseArray() [1/2]
template<typename Component >
Default copy constructor.
- Parameters
-
◆ SparseArray() [2/2]
template<typename Component >
Default move constructor.
- Parameters
-
◆ begin() [1/2]
template<typename Component >
Return the iterator pointing to the beginning of the SparseArray.
- Template Parameters
-
Component | Type of the component |
- Returns
- Iterator pointing to the beginning of the SparseArray
◆ begin() [2/2]
template<typename Component >
Return the const_iterator pointing to the beginning of the SparseArray.
- Template Parameters
-
Component | Type of the component |
- Returns
- ConstIterator pointing to the beginning of the SparseArray
◆ cbegin()
template<typename Component >
Return the const_iterator pointing to the beginning of the SparseArray.
- Template Parameters
-
Component | Type of the component |
- Returns
- ConstIterator pointing to the beginning of the SparseArray
◆ cend()
template<typename Component >
Return the const_iterator pointing to the end of the SparseArray.
- Template Parameters
-
Component | Type of the component |
- Returns
- ConstIterator pointing to the end of the SparseArray
◆ emplaceAt()
template<typename Component >
template<class... Params>
Emplace a component at the given index.
- Template Parameters
-
Params | Types of the parameters to construct the component |
- Parameters
-
pos | Index to emplace the component |
params | Parameters to construct the component |
- Returns
- Reference to the inserted component
- Note
- The component is constructed in place or moved into the SparseArray
◆ end() [1/2]
template<typename Component >
Return the iterator pointing to the end of the SparseArray.
- Template Parameters
-
Component | Type of the component |
- Returns
- Iterator pointing to the end of the SparseArray
◆ end() [2/2]
template<typename Component >
Return the const_iterator pointing to the end of the SparseArray.
- Template Parameters
-
Component | Type of the component |
- Returns
- ConstIterator pointing to the end of the SparseArray
◆ erase()
template<typename Component >
Erase the component at the given index.
- Template Parameters
-
Component | Type of the component |
- Parameters
-
pos | Index of the component to erase |
◆ getData()
template<typename Component >
Get the _data container.
- Returns
- Reference to the _data container
◆ getIndex()
template<typename Component >
Get the index of the entity possessing the given component.
- Template Parameters
-
Component | Type of the component |
- Parameters
-
ptr | Pointer to the component |
- Returns
- Optional containing the index of the entity possessing the given component or nullopt if the component is not found
◆ insertAt() [1/2]
template<typename Component >
Insert a component at the given index.
- Template Parameters
-
Component | Type of the component |
- Parameters
-
pos | Index to insert the component |
component | Component to insert |
- Returns
- Reference to the inserted component
- Note
- The component is moved
◆ insertAt() [2/2]
template<typename Component >
Insert a component at the given index.
- Template Parameters
-
Component | Type of the component |
- Parameters
-
pos | Index to insert the component |
component | Component to insert |
- Returns
- Reference to the inserted component
◆ operator=() [1/2]
template<typename Component >
Copy assignment operator.
- Template Parameters
-
Component | Type of the component |
- Parameters
-
- Returns
- Reference to the current SparseArray
◆ operator=() [2/2]
template<typename Component >
Move assignment operator.
- Template Parameters
-
Component | Type of the component |
- Parameters
-
- Returns
- Reference to the current SparseArray
◆ operator[]() [1/2]
template<typename Component >
Access the component at the given index, if it exists, otherwise resize the SparseArray.
- Template Parameters
-
Component | Type of the component |
- Parameters
-
idx | Index to get the component |
- Returns
- Reference to the component
◆ operator[]() [2/2]
template<typename Component >
Access the component at the given index, if it exists, otherwise return nullptr.
- Template Parameters
-
Component | Type of the component |
- Parameters
-
idx | Index to get the component |
- Returns
- Reference to the component if it exists, nullptr otherwise
◆ size()
template<typename Component >
Return the size of the SparseArray.
- Template Parameters
-
Component | Type of the component |
- Returns
- Size of the SparseArray
The documentation for this class was generated from the following file: