42 inline unsigned int num()
const {
return length;}
44 inline T*
atBoundsCheck(
unsigned int pos)
const {
return (pos<length) ? block[pos] :
nullptr; }
46 inline T*
at(
unsigned int pos)
const {
return block[pos]; }
50 inline T*
first()
const {
return at(0);}
54 inline T*
last()
const {
return at(length-1);}
56 virtual unsigned int append(
T*
elem);
58 virtual void swap(
unsigned int p1,
unsigned int p2);
63 virtual void deleteAt(
unsigned int pos);
65 virtual void deleteLast();
67 virtual int remove(
T*
elem);
69 virtual int lookup(
T*
elem)
const;
71 virtual int removeUnSwapped(
T*
elem);
74 virtual void destroy();
76 virtual void replace(
T*
elem,
unsigned int pos);
78 void reserve(
unsigned int init);
85 unsigned int capacity;
86 unsigned int BLOCKSIZE;
93 virtual void expand();
96 virtual unsigned int appendUnsafe(
T*
elem);
129 block =
new T * [capacity];
151 length = capacity = 0;
159 for (
unsigned int i = 0;
i < length; ++
i)
161 delete block[
i]; block[
i] =
nullptr;
174 for (
unsigned int i = 0;
i < length; ++
i)
182 capacity += BLOCKSIZE;
192 if (length == capacity)
196 block[length] =
elem;
207 if (length == capacity)
211 block[length] =
elem;
260 block[length] =
nullptr;
270 for (
unsigned int i = 0;
i < length; ++
i)
274 pos =
static_cast<int>(
i);
286 int pos = lookup(
elem);
289 deleteAt(
static_cast<unsigned int>(pos));
299 const int pos = lookup(
elem);
302 for (
unsigned int i =
static_cast<unsigned int>(pos);
i < length-1; ++
i)
304 block[
i] = block[
i+1];
316 if (init <= capacity)
322 for (
unsigned int i = 0;
i < length; ++
i)
Dynamic templated vector For speed and better memory handling, the vector is an array within an array...
unsigned int num() const
Returns number of elements in the vector.
T * lastBoundsCheck() const
Returns last element, return NULL when out of range.
virtual void destroy()
Deletes all elements in the vector This does not reset the number of elements!!
T * atBoundsCheck(unsigned int pos) const
Returns element at given position, return NULL when out of range.
T * firstBoundsCheck() const
Returns first element, return NULL when out of range.
T * at(unsigned int pos) const
Returns element at given position.
T * last() const
Returns last element.
T * first() const
Returns first element.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
void deleteVector(CSOObjectVector< T > *vector, bool deleteEntries=true)