21 #ifndef SRC_ENTITY_SYSTEM_VECTOR_PROPERTY_H
22 #define SRC_ENTITY_SYSTEM_VECTOR_PROPERTY_H
29 namespace entity_system{
39 std::vector<T> m_values;
41 inline void m_range_check(
size_t index)
const {
42 if(index >= m_values.size())
43 throw std::out_of_range(
"vector::_M_range_check");
51 void destroy(entity_index e ) {
52 std::size_t last_index = m_values.size() - 1;
53 m_values[e] = m_values[last_index];
62 m_values.push_back(T());
70 void preallocate( std::size_t qnt ) {
71 m_values.reserve(std::max(m_values.capacity(), qnt));
112 T &
at(entity_index e) {
125 const T &
at(entity_index e)
const {
137 typename std::vector<T>::const_iterator
begin()
const {
138 return m_values.begin();
146 typename std::vector<T>::const_iterator
end()
const {
147 return m_values.end();
151 return m_values.data();
154 const T* data()
const {
155 return m_values.data();
161 std::vector<bool> m_values;
163 inline void m_range_check(
size_t index)
const {
164 if(index >= m_values.size())
165 throw std::out_of_range(
"vector::_M_range_check");
168 void destroy( entity_index e ) {
169 std::size_t last_index = m_values.size() - 1;
170 m_values[e] = m_values[last_index];
175 m_values.push_back(
bool());
178 void preallocate( std::size_t qnt ) {
179 m_values.reserve(std::max(m_values.capacity(), qnt));
191 bool operator[](std::size_t entity_index)
const {
192 return m_values[entity_index];
195 std::vector<bool>::reference
operator[](std::size_t entity_index) {
196 return m_values[entity_index];
199 bool at(std::size_t entity_index)
const {
201 m_range_check(entity_index);
203 return m_values[entity_index];
206 std::vector<bool>::reference
at(std::size_t entity_index) {
208 m_range_check(entity_index);
210 return m_values[entity_index];
213 std::vector<bool>::const_iterator
begin()
const {
214 return m_values.begin();
217 std::vector<bool>::const_iterator
end()
const {
218 return m_values.end();
226 #endif //SRC_ENTITY_SYSTEM_VECTOR_PROPERTY_H
T & operator[](entity_index e)
Property getter.
Definition: vector_property.h:92
T & at(entity_index e)
Property getter with range check.
Definition: vector_property.h:112
std::vector< T >::const_iterator begin() const
Begin iterator.
Definition: vector_property.h:137
const T & operator[](entity_index e) const
Constant property getter.
Definition: vector_property.h:102
std::vector< T >::const_iterator end() const
End iterator.
Definition: vector_property.h:146
const T & at(entity_index e) const
Constant property getter with range check.
Definition: vector_property.h:125
Implementation of the vector property class.
Definition: vector_property.h:37
Property class.
Definition: property.h:33
vector_property()
Constructor.
Definition: vector_property.h:79