18 #ifndef AGXDATA_VECTOR_H 19 #define AGXDATA_VECTOR_H 55 void resize(
size_t size,
const T& value = T());
65 T*
increment(
size_t numElements = 1,
const T& value = T());
72 template <
typename T2>
84 iterator
erase(iterator position);
85 iterator
erase(iterator start, iterator
end);
90 void erase(
size_t index);
91 void erase(
size_t start,
size_t end);
96 iterator
eraseFast(const_iterator position);
110 template <
typename T2>
111 bool findAndErase(
const T2& element,
bool searchMultiple =
false);
113 iterator
insert(iterator position,
const T& value);
114 void insert(
size_t index,
const T& value);
116 template <
typename InputIterator>
117 void insert(iterator it, InputIterator first, InputIterator last);
120 void reallocate(
size_t size);
129 template <
typename T>
134 template <
typename T>
140 template <
typename T>
146 template <
typename T>
164 template <
typename T>
176 this->reallocate(size);
182 template <
typename T>
190 template <
typename T>
194 this->reallocate(size);
197 template <
typename T>
203 size_t newSize = currentSize + numElements;
210 for(
size_t i = currentSize; i < newSize; ++i)
211 ::
new((
void *)(this->
ptr() + i)) T(value);
213 return this->
ptr() + currentSize;
216 template <
typename T>
223 for (
size_t i = newSize; i < this->
buffer()->
m_size; ++i)
230 template <
typename T>
template <
typename T2>
240 ::new((
void *)&this->
back()) T(value);
243 template <
typename T>
254 template <
typename T>
259 size_t index = position - this->
begin();
261 return this->
begin() + index;
264 template <
typename T>
269 size_t startIndex = start - this->
begin();
270 size_t endIndex = end - this->
begin();
271 this->
erase(startIndex, endIndex);
273 return this->
begin() + endIndex;
276 template <
typename T>
281 for (
size_t i = index + 1; i < this->
buffer()->
m_size; i++)
282 this->
ptr()[i-1] = this->
ptr()[i];
290 template <
typename T>
296 size_t numElements = end - start;
300 this->
ptr()[i-numElements] = this->
ptr()[i];
309 template <
typename T>
314 size_t index = position - this->
begin();
316 return this->
begin() + index;
319 template <
typename T>
323 agxAssertN(index < this->
buffer()->
m_size,
"Array index %llu is out of bounds, current size is %llu", (
long long unsigned)index, (
long long unsigned)this->
buffer()->
m_size);
330 template <
typename T>
337 template <
typename T>
template <
typename T2>
346 if (this->
ptr()[i] == element)
361 template <
typename T>
366 size_t index = position - this->
begin();
367 this->
insert(index, value);
368 return this->
begin() + index;
371 template <
typename T>
381 for (
size_t i = this->
buffer()->
m_size; i > index; i--) {
382 ::new((
void *)&this->
ptr()[i]) T(this->
ptr()[i-1]);
383 this->
ptr()[i-1].~T();
386 ::new((
void *)&this->
ptr()[index]) T(value);
390 template <
typename T>
template <
typename InputIterator>
395 size_t numElements = std::distance( first, last );
397 if (numElements == 0)
400 size_t index = it - this->
begin();
405 for (
size_t i = this->
buffer()->
m_size; i > index; i--) {
406 ::new((
void *)&this->
ptr()[i + numElements - 1]) T(this->
ptr()[i-1]);
407 this->
ptr()[i-1].~T();
410 for (; first != last; first++)
411 ::
new((
void *)&this->
ptr()[index++]) T(*first);
EventDispatch m_eventDispatch
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
void clear()
Remove all elements, optionally with maintained buffer allocation.
Vector< agx::UInt32 > GenericVector
#define agxAssertN(expr, format,...)
void commit()
Commit all changes.
void reserve(size_t size)
Reserve space for future buffer expansion.
void pop_back()
Remove the back element.
void resize(size_t size, const T &value=T())
Resize the vector, which then enables direct addressing using the bracket '[]' operator.
const T & const_reference
iterator eraseFast(const_iterator position)
Fast erase, replacing the erased element with the last element.
iterator insert(iterator position, const T &value)
ptrdiff_t difference_type
agx::IndexRange32 & range()
Type-specific Array used for fast access into the data held by a Buffer.
void reserve(size_t size)
Reserve capacity in the vector.
T * increment(size_t numElements=1, const T &value=T())
Resize using a increment.
static agx::Real CAPACITY_MULTIPLIER
Abstract representation of a data buffer.
Contains classes for low level data storage for AGX.
agxData::ValueRefT< agx::UInt > sizeParameter
void sync()
Updates the internal data access pointer. Called when the back end buffer is reallocated.
agxData::EntityStorage * getStorage()
void decrement(size_t numElements=1)
const agxData::Buffer * buffer() const
std::random_access_iterator_tag iterator_category
#define AGX_TEMPLATED_TYPE_BINDING(_Type, _Name)
iterator erase(iterator position)
STL erase functionality.
#define agxAssert1(expr, msg)
bool findAndErase(const T2 &element, bool searchMultiple=false)
Find and erase an element.
#define AGX_VECTOR_SHRINK_THRESHOLD
void push_back(const T2 &value)
Append a new data element to the vector.