![]() |
Shkyera Engine
Easy to use, game engine for Python
|
#include <SparseSet.hpp>
Classes | |
| class | Iterator |
Public Types | |
| using | iterator = Iterator< false > |
| using | const_iterator = Iterator< true > |
Public Member Functions | |
| SparseSet ()=default | |
| ~SparseSet ()=default | |
| std::unique_ptr< SparseSetBase > | clone () const override |
| bool | add (Entity entity, Component component) |
| bool | remove (Entity entity) override |
| void | clear () |
| bool | contains (Entity entity) const |
| Component & | get (Entity entity) |
| const Component & | get (Entity entity) const |
| std::vector< Component > & | getComponents () |
| const std::vector< Component > & | getComponents () const |
| bool | empty () const |
| size_t | size () const |
| iterator | begin () |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
Public Member Functions inherited from shkyera::SparseSetBase | |
| virtual | ~SparseSetBase ()=default |
Private Attributes | |
| std::vector< Entity > | _entities |
| std::unordered_map< Entity, size_t > | _entityToComponent |
| std::vector< Component > | _components |
Manages a sparse set of components associated with entities. Allows adding, removing, and accessing components efficiently.
| using shkyera::SparseSet< Component >::const_iterator = Iterator<true> |
|
default |
Default constructor.
|
default |
Default destructor.
|
inline |
Adds a component for the specified entity.
| entity | The entity to associate with the component. |
| component | The component to add. |
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Implements shkyera::SparseSetBase.
|
inline |
Checks if the specified entity has an associated component.
| entity | The entity to check. |
|
inline |
Check if there is at least one entity with a component.
|
inline |
|
inline |
|
inline |
Retrieves a reference to the component associated with the specified entity.
| entity | The entity whose component is to be retrieved. |
|
inline |
Retrieves a const reference to the component associated with the specified entity.
| entity | The entity whose component is to be retrieved. |
|
inline |
Retrieves a vector of all components in the sparse set.
|
inline |
Retrieves a const vector of all components in the sparse set.
|
inlineoverridevirtual |
Removes the component associated with the specified entity.
| entity | The entity whose component is to be removed. |
Implements shkyera::SparseSetBase.
|
inline |
|
private |
Stores components associated with entities.
|
private |
Stores entities associated with components.
|
private |
Maps entities to their component indices.