ecs
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
ecs::SparseArray< Component > Class Template Reference

SparseArray class. More...

#include <SparseArray.hpp>

Public Types

using value_type = std::optional< Component >
 
using reference_type = value_type &
 
using const_reference_type = value_type const &
 
using container_t = std::vector< value_type >
 
using size_type = typename container_t::size_type
 
using iterator = typename container_t::iterator
 
using const_iterator = typename container_t::const_iterator
 

Public Member Functions

 SparseArray ()=default
 construct a new SparseArray object
 
 SparseArray (SparseArray const &)=default
 copy constructor
 
 SparseArray (SparseArray &&) noexcept=default
 move constructor
 
 ~SparseArray ()=default
 Destroy the Sparse Array object.
 
SparseArrayoperator= (SparseArray const &)=default
 copy operator=
 
SparseArrayoperator= (SparseArray &&) noexcept=default
 move operator=
 
reference_type operator[] (size_t idx)
 give the value at the index idx of the SparseArray
 
const_reference_type operator[] (size_t idx) const
 give the value at the index idx of the SparseArray (const)
 
iterator begin ()
 give a iterator at the begining of the SparseArray
 
const_iterator begin () const
 give a const_iterator at the begining of the SparseArray
 
const_iterator cbegin () const
 give a const_iterator at the begining of the SparseArray
 
iterator end ()
 give a iterator at the end of the SparseArray
 
const_iterator end () const
 give a const_iterator at the end of the SparseArray
 
const_iterator cend () const
 give a const_iterator at the end of the SparseArray
 
size_type size () const
 give the size of the SparseArray
 
reference_type insertAt (size_type pos, Component const &c)
 insert a component at the given position & return a reference to it
 
reference_type insertAt (size_type pos, Component &&c)
 insert a component at the given position & return a reference to it
 
template<class ... Params>
reference_type emplaceAt (size_type pos, Params &&...args)
 emplace a component at the given position & return a reference to it
 
void erase (size_type pos)
 erase the component at the given position
 
size_type getIndex (const value_type &v) const
 get the index of the given value
 
void print () const
 print the SparseArray
 

Detailed Description

template<typename Component>
class ecs::SparseArray< Component >

SparseArray class.

Template Parameters
Component

Member Typedef Documentation

◆ const_iterator

template<typename Component >
using ecs::SparseArray< Component >::const_iterator = typename container_t::const_iterator

◆ const_reference_type

template<typename Component >
using ecs::SparseArray< Component >::const_reference_type = value_type const &

◆ container_t

template<typename Component >
using ecs::SparseArray< Component >::container_t = std::vector<value_type>

◆ iterator

template<typename Component >
using ecs::SparseArray< Component >::iterator = typename container_t::iterator

◆ reference_type

template<typename Component >
using ecs::SparseArray< Component >::reference_type = value_type &

◆ size_type

template<typename Component >
using ecs::SparseArray< Component >::size_type = typename container_t::size_type

◆ value_type

template<typename Component >
using ecs::SparseArray< Component >::value_type = std::optional<Component>

Constructor & Destructor Documentation

◆ SparseArray() [1/3]

template<typename Component >
ecs::SparseArray< Component >::SparseArray ( )
default

construct a new SparseArray object

◆ SparseArray() [2/3]

template<typename Component >
ecs::SparseArray< Component >::SparseArray ( SparseArray< Component > const &  )
default

copy constructor

Parameters
size

◆ SparseArray() [3/3]

template<typename Component >
ecs::SparseArray< Component >::SparseArray ( SparseArray< Component > &&  )
defaultnoexcept

move constructor

Parameters
size

◆ ~SparseArray()

template<typename Component >
ecs::SparseArray< Component >::~SparseArray ( )
default

Destroy the Sparse Array object.

Member Function Documentation

◆ begin() [1/2]

template<typename Component >
iterator ecs::SparseArray< Component >::begin ( )
inline

give a iterator at the begining of the SparseArray

Returns
iterator

◆ begin() [2/2]

template<typename Component >
const_iterator ecs::SparseArray< Component >::begin ( ) const
inline

give a const_iterator at the begining of the SparseArray

Returns
const_iterator

◆ cbegin()

template<typename Component >
const_iterator ecs::SparseArray< Component >::cbegin ( ) const
inline

give a const_iterator at the begining of the SparseArray

Returns
const_iterator

◆ cend()

template<typename Component >
const_iterator ecs::SparseArray< Component >::cend ( ) const
inline

give a const_iterator at the end of the SparseArray

Returns
const_iterator

◆ emplaceAt()

template<typename Component >
template<class ... Params>
reference_type ecs::SparseArray< Component >::emplaceAt ( size_type  pos,
Params &&...  args 
)
inline

emplace a component at the given position & return a reference to it

Template Parameters
Params
Parameters
pos
args
Returns
reference_type

◆ end() [1/2]

template<typename Component >
iterator ecs::SparseArray< Component >::end ( )
inline

give a iterator at the end of the SparseArray

Returns
iterator

◆ end() [2/2]

template<typename Component >
const_iterator ecs::SparseArray< Component >::end ( ) const
inline

give a const_iterator at the end of the SparseArray

Returns
const_iterator

◆ erase()

template<typename Component >
void ecs::SparseArray< Component >::erase ( size_type  pos)
inline

erase the component at the given position

Parameters
pos

◆ getIndex()

template<typename Component >
size_type ecs::SparseArray< Component >::getIndex ( const value_type v) const
inline

get the index of the given value

Parameters
v
Returns
size_type

◆ insertAt() [1/2]

template<typename Component >
reference_type ecs::SparseArray< Component >::insertAt ( size_type  pos,
Component &&  c 
)
inline

insert a component at the given position & return a reference to it

Parameters
pos
c
Returns
reference_type

◆ insertAt() [2/2]

template<typename Component >
reference_type ecs::SparseArray< Component >::insertAt ( size_type  pos,
Component const &  c 
)
inline

insert a component at the given position & return a reference to it

Parameters
pos
c
Returns
reference_type

◆ operator=() [1/2]

template<typename Component >
SparseArray & ecs::SparseArray< Component >::operator= ( SparseArray< Component > &&  )
defaultnoexcept

move operator=

Parameters
other
Returns
SparseArray&

◆ operator=() [2/2]

template<typename Component >
SparseArray & ecs::SparseArray< Component >::operator= ( SparseArray< Component > const &  )
default

copy operator=

Parameters
other
Returns
SparseArray&

◆ operator[]() [1/2]

template<typename Component >
reference_type ecs::SparseArray< Component >::operator[] ( size_t  idx)
inline

give the value at the index idx of the SparseArray

Parameters
idx
Returns
reference_type

◆ operator[]() [2/2]

template<typename Component >
const_reference_type ecs::SparseArray< Component >::operator[] ( size_t  idx) const
inline

give the value at the index idx of the SparseArray (const)

Parameters
idx
Returns
const_reference_type

◆ print()

template<typename Component >
void ecs::SparseArray< Component >::print ( ) const
inline

print the SparseArray

◆ size()

template<typename Component >
size_type ecs::SparseArray< Component >::size ( ) const
inline

give the size of the SparseArray

Returns
size_type

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