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]; }
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);
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;
171 T* *newblock =
nullptr;
172 newblock =
new T*[capacity+BLOCKSIZE];
174 for (
unsigned int i = 0; i < length; ++i)
176 newblock[i] = block[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)
320 T* *newblock =
nullptr;
321 newblock =
new T*[
init];
322 for (
unsigned int i = 0; i < length; ++i)
324 newblock[i] = block[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.
virtual void destroy()
Deletes all elements in the vector This does not reset the number of elements!!
T * first() const
Returns first element.
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 * lastBoundsCheck() const
Returns last element, return NULL when out of range.
IteratorTraits::value_type & at(const ml_iterator_map< IteratorTraits, IDMap > &i, typename property_traits< IDMap >::key_type key)
void init()
Initializes the ML, the runtime type system, the memory manager, fields, static buffers,...
void destroy()
Delete dynamic data structures allocated by init().
void deleteVector(CSOObjectVector< T > *vector, bool deleteEntries=true)