|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Sparse array container for component storage. More...
#include <SparseArray.hpp>
Public Types | |
| using | value_type = T |
| using | container_t = std::vector< value_type > |
Public Member Functions | |
| SparseArray ()=default | |
| SparseArray (const SparseArray &)=default | |
| SparseArray (SparseArray &&) noexcept=default | |
| SparseArray & | operator= (const SparseArray &)=default |
| SparseArray & | operator= (SparseArray &&) noexcept=default |
| ~SparseArray () override=default | |
| void | erase (Entity entity) noexcept override final |
| Remove a component from an entity. | |
| bool | has (Entity entity) const noexcept override final |
| Check if an entity has this component. | |
| void | clear (void) noexcept override final |
| Remove all components. | |
| template<typename Self > | |
| auto && | operator[] (this Self &self, Entity entity) noexcept |
| Access component by entity. | |
| template<typename... Args> | |
| T & | emplace (Entity entity, Args &&...args) |
| Construct a component in-place for an entity. | |
| std::span< T > | data () noexcept |
| Get the underlying dense component array. | |
| std::span< const T > | data () const noexcept |
| std::span< Entity > | entities () noexcept |
| Get the entity array corresponding to components. | |
| std::span< const Entity > | entities () const noexcept |
| std::size_t | size (void) const noexcept |
| Get the number of components stored. | |
| bool | empty (void) const noexcept |
| Check if the array is empty. | |
Public Member Functions inherited from rtp::ecs::ISparseArray | |
| virtual | ~ISparseArray () noexcept=default |
Static Public Attributes | |
| static constexpr std::size_t | NullIndex |
Private Attributes | |
| std::vector< size_t > | _sparse |
| The Sparse Array (The Map) | |
| std::vector< Entity > | _dense |
| The Dense Entity Array (The Reverse Lookup) | |
| container_t | _data |
| The Dense Component Array (The Cache Friendly Data) | |
Sparse array container for component storage.
| T | The component type to store |
Implements an efficient sparse set data structure that:
Definition at line 95 of file SparseArray.hpp.
| using rtp::ecs::SparseArray< T >::container_t = std::vector<value_type> |
Definition at line 98 of file SparseArray.hpp.
| using rtp::ecs::SparseArray< T >::value_type = T |
Definition at line 97 of file SparseArray.hpp.
|
default |
|
default |
|
defaultnoexcept |
|
overridedefault |
|
finaloverridevirtualnoexcept |
Remove all components.
Implements rtp::ecs::ISparseArray.
|
noexcept |
|
noexcept |
Get the underlying dense component array.
| T & rtp::ecs::SparseArray< T >::emplace | ( | Entity | entity, |
| Args &&... | args | ||
| ) |
|
noexcept |
|
noexcept |
|
noexcept |
Get the entity array corresponding to components.
Referenced by TEST().
|
finaloverridevirtualnoexcept |
Remove a component from an entity.
| entity | The entity whose component to remove |
Implements rtp::ecs::ISparseArray.
|
finaloverridevirtualnoexcept |
Check if an entity has this component.
| entity | The entity to check |
Implements rtp::ecs::ISparseArray.
Referenced by TEST().
|
default |
|
defaultnoexcept |
|
noexcept |
Access component by entity.
| Self | Deduced self type (const or non-const) |
| entity | The entity to get the component for |
|
noexcept |
|
private |
The Dense Component Array (The Cache Friendly Data)
Definition at line 204 of file SparseArray.hpp.
|
private |
The Dense Entity Array (The Reverse Lookup)
Definition at line 203 of file SparseArray.hpp.
|
private |
The Sparse Array (The Map)
Definition at line 202 of file SparseArray.hpp.
|
staticconstexpr |
Definition at line 100 of file SparseArray.hpp.