54template <
class T,
class TAlloc = TDefaultAllocator<T> >
81 void add(
const T &newValue);
185 size_t mCapacity{0u};
189template <
class T,
class TAlloc>
196template <
class T,
class TAlloc>
199 for (
size_t i = 0u; i < mSize; ++i) {
200 mData[i] = rhs.mData[i];
204template <
class T,
class TAlloc>
209template <
class T,
class TAlloc>
211 if (mSize + 1 > mCapacity) {
215 mData[mSize] = value;
219template <
class T,
class TAlloc>
221 if (0 == numItems || newValues ==
nullptr) {
225 const size_t newCapa = mSize + numItems;
226 if (newCapa > mCapacity) {
229 for (
size_t i = 0; i < numItems; ++i) {
230 mData[mSize] = newValues[i];
235template <
class T,
class TAlloc>
237 assert(index < mSize);
239 if (index == mSize - 1) {
245 this->
move(index + 1, index);
249template <
class T,
class TAlloc>
256 for (
size_t i = 0; i < mSize; ++i) {
257 if (it == currentIt) {
258 pos =
static_cast<long>(i);
270template <
class T,
class TAlloc>
277template <
class T,
class TAlloc>
283 for (
size_t i = 0; i <
size(); ++i) {
288template <
class T,
class TAlloc>
290 T *pElem = &(mData[index]);
294template <
class T,
class TAlloc>
301template <
class T,
class TAlloc>
305 return (mData[mSize - 1]);
308template <
class T,
class TAlloc>
312 return (mData[mSize - 1]);
315template <
class T,
class TAlloc>
317 if (fromIdx == toIdx) {
321 const size_t numElements = mSize - fromIdx;
322 const size_t newSize = toIdx + numElements;
323 while (mCapacity < newSize) {
328 if (fromIdx > toIdx) {
329 for (
size_t i = 0; i < numElements; ++i) {
330 mData[toIdx + i] = mData[fromIdx + i];
333 for (
size_t i = toIdx; i < fromIdx + 1; --i) {
338 for (
size_t i = numElements - 1; i != 0; --i) {
339 mData[toIdx + i] = mData[fromIdx + i];
342 for (
size_t i = 0; i < numElements; i++) {
348 mSize = toIdx + numElements;
351template <
class T,
class TAlloc>
359 tmp = mAllocator.alloc(mSize);
360 for (
size_t i = 0u; i < mSize; ++i) {
366 mAllocator.release(mData);
374 for (
size_t i = 0u; i < mSize; ++i) {
377 mAllocator.release(tmp);
381template <
class T,
class TAlloc>
383 const size_t oldSize = mSize;
387 if (mSize > 0u && mCapacity <
size) {
388 tmp = mAllocator.alloc(mSize *
sizeof(T));
389 for (
size_t i = 0u; i < mSize; ++i) {
393 mAllocator.release(mData);
399 if (
size > mCapacity) {
400 mData = mAllocator.alloc(
size *
sizeof(T));
402 for (
size_t i = 0u; i < oldSize; ++i) {
405 mAllocator.release(tmp);
412template <
class T,
class TAlloc>
416 for (
size_t i = 0u; i <
size; ++i) {
422template <
class T,
class TAlloc>
427template <
class T,
class TAlloc>
432template <
class T,
class TAlloc>
434 return (0u == mSize);
437template <
class T,
class TAlloc>
448template <
class T,
class TAlloc>
450 mAllocator.release(mData);
456template <
class T,
class TAlloc>
465template <
class T,
class TAlloc>
473template <
class T,
class TAlloc>
478template <
class T,
class TAlloc>
481 assert(
nullptr != mData);
486template <
class T,
class TAlloc>
488 if (other == *
this) {
494 assert(
nullptr != other.mData);
496 for (
size_t i = 0u; i < other.
size(); ++i) {
497 mData[i] = other.mData[i];
506template <
class T,
class TAlloc>
508 if (rhs.mSize != mSize) {
512 for (
size_t i = 0u; i < mSize; ++i) {
513 if (mData[i] != rhs.mData[i]) {
bool operator==(const TArray< T, TAlloc > &rOther) const
The compare operator.
TArray(const TArray< T, TAlloc > &rhs)
The copy constructor.
void resize(array_size_type size, T val)
Resize the array, new items will be created.
bool isEmpty() const
Returns true, if the array is empty.
Iterator linearSearch(const T &item)
Performs a linear search for a given item in the array.
T & front()
Returns the first item.
void removeBack()
The last item will be removed.
TArray()=default
The default class constructor.
void destroy(array_size_type index)
The item at the given index will be destroyed, the destructor will be called manually.
void clear()
The array will be cleared, destructor of the items will be called.
const T & back() const
Returns the last item as a const reference.
void remove(array_size_type index)
Removes an item at the given index.
void remove(Iterator it)
Removes the item describes by a given iterator.
void reserve(array_size_type capacity)
Ensures, that the capacity of the array is big enough for the given size.
void resize(array_size_type size)
Resize the array, new items will be created.
AbstractLogStream ** Iterator
Iterator begin()
Returns an iterator showing to the first item.
T & back()
Returns the last item.
T & operator[](array_size_type idx) const
The [] operator.
void add(const T *newValues, array_size_type numItems)
An array of new items will be added to the array.
T * data() const
Will return the data pointer.
Iterator end()
Returns an iterator showing to the end of the array.
const AbstractLogStream ** ConstIterator
void add(const T &newValue)
A new item will be added to the array.
void move(array_size_type startIdx, array_size_type endIdx)
Moves the items from the start- to the end-index.
void set(const T &value)
Will set all items to the value.
TArray(array_size_type size)
The class constructor with an initial size.
~TArray()
The class destructor.
TArray< T, TAlloc > & operator=(const TArray< T, TAlloc > &rhs)
The assignment operator.
static size_t getGrowing(size_t size)