12 template <Val
idEntity entityType,
typename ComponentType>
18 template <Val
idEntity entityType>
47 m_dense.push_back({
entity});
49 if (m_sparse.size() <= entity_index)
50 m_sparse.resize(entity_index + 1);
52 auto dense_index = m_dense.size() - 1;
53 m_sparse[entity_index] = dense_index;
62 size_t dense_index = m_sparse[entity_index];
64 if (m_dense.size() > 1)
67 entityType last_entity = m_dense.back();
70 m_sparse[last_entity_index] = dense_index;
72 std::swap(m_dense[dense_index], m_dense.back());
117 return m_sparse[entity_index];
130 m_sparse.size() > entity_index
131 && m_sparse[entity_index] < m_dense.size()
132 && m_dense[m_sparse[entity_index]] ==
entity);
137 return m_dense.size();
static constexpr uint32_t getEntityIndex(const entityType &entity)
Get the index of the entity in the entity array, see the entity doc for more info.
Definition: Manager.hpp:137
Definition: SparseSet.hpp:20
const_reverse_iterator rend() const
Definition: SparseSet.hpp:148
size_t index(entityType entity) const
Definition: SparseSet.hpp:114
SparseSet & operator=(SparseSet &&other)=default
dense_type::const_iterator const_iterator
Definition: SparseSet.hpp:27
SparseSet & operator=(SparseSet &other)=default
size_t insert(entityType entity)
Definition: SparseSet.hpp:41
reverse_iterator rbegin()
Definition: SparseSet.hpp:142
const_reverse_iterator rbegin() const
Definition: SparseSet.hpp:143
std::vector< size_t > sparse_type
Definition: SparseSet.hpp:24
size_t size() const
Definition: SparseSet.hpp:135
dense_type::const_reverse_iterator const_reverse_iterator
Definition: SparseSet.hpp:29
const_iterator end() const
Definition: SparseSet.hpp:146
reverse_iterator rend()
Definition: SparseSet.hpp:147
dense_type::iterator iterator
Definition: SparseSet.hpp:26
dense_type::reverse_iterator reverse_iterator
Definition: SparseSet.hpp:28
std::vector< node_type > dense_type
Definition: SparseSet.hpp:23
entityType node_type
Definition: SparseSet.hpp:22
SparseSet(SparseSet &other)=default
virtual ~SparseSet()=default
iterator begin()
Definition: SparseSet.hpp:140
const_iterator begin() const
Definition: SparseSet.hpp:141
SparseSet()
Definition: SparseSet.hpp:31
SparseSet(SparseSet &&other)=default
virtual size_t remove(entityType entity)
Definition: SparseSet.hpp:57
SparseSet(size_t size)
Definition: SparseSet.hpp:32
iterator end()
Definition: SparseSet.hpp:145
bool contains(entityType entity) const
Definition: SparseSet.hpp:120
Definition: ComponentStorage.hpp:9
uint32_t entity
Definition: ecs_CONSTANTS.hpp:10
Definition: SparseSet.hpp:14
entityType entity
Definition: SparseSet.hpp:15