ecs::SparseArray

More...

#include <SparseArray.hpp>

Public Types

Name

using std::optional< Component >

using std::vector< valueType >

using typename container::size_type

using typename container::iterator

using typename container::const_iterator

Public Functions

Name

Detailed Description

template <typename Component >
class ecs::SparseArray;

Template Parameters:

  • Component The type of component used as with template

SparseArray class is the component container of the ecs.

This can be quite useful to store components that are defined for most entities, because you don't have to store the entity ID alongside the component.

Public Types Documentation

using valueType

using ecs::SparseArray< Component >::valueType =  std::optional<Component>;

using referenceType

using ecs::SparseArray< Component >::referenceType =  valueType &;

using constReferenceType

using ecs::SparseArray< Component >::constReferenceType =  valueType const &;

using container

using ecs::SparseArray< Component >::container =  std::vector<valueType>;

using sizeType

using ecs::SparseArray< Component >::sizeType =  typename container::size_type;

using iterator

using ecs::SparseArray< Component >::iterator =  typename container::iterator;

using constIterator

using ecs::SparseArray< Component >::constIterator =  typename container::const_iterator;

Public Functions Documentation

function SparseArray

inline SparseArray()

Default constructor & destructor of the SparseArray class

function SparseArray

inline SparseArray(
    SparseArray const & other
)

function SparseArray

inline SparseArray(
    SparseArray && other
)

function ~SparseArray

~SparseArray() =default

function operator=

inline SparseArray & operator=(
    SparseArray const & other
)

Parameters:

Return: The Sparse array present in the class at the moment

Operator copy of the SparseArray class

function operator=

inline SparseArray & operator=(
    SparseArray && other
)

Parameters:

Return: The Sparse array present in the class at the moment

Operator move of the SparseArray class

function operator[]

inline referenceType operator[](
    size_t idx
)

function operator[]

inline constReferenceType operator[](
    size_t idx
) const

function begin

inline iterator begin()

function begin

inline constIterator begin() const

function cBegin

inline constIterator cBegin() const

function end

inline iterator end()

function end

inline constIterator end() const

function cEnd

inline constIterator cEnd() const

function size

inline sizeType size() const

function insertAt

inline referenceType insertAt(
    sizeType pos,
    Component const & c
)

function insertAt

inline referenceType insertAt(
    sizeType pos,
    Component && c
)

function emplaceAt

template <class... Params>
inline referenceType emplaceAt(
    sizeType pos,
    Params &&... args
)

function erase

inline void erase(
    sizeType pos
)

function getIndex

inline sizeType getIndex(
    valueType const & c
) const

Parameters:

  • c The std::optional, type of the component you want the index

Return: The sizeType of the valueType's index you are looking for

This function is used to get the index of the std::optional of the std::vector<std::optional> _data according to the given valueType (std::optional)


Updated on 2022-11-13 at 17:21:37 +0100

Last updated