40 inline unsigned int num()
const
47 return (pos < length) ? block[pos] :
nullptr;
50 inline T*
at(
unsigned int pos)
const
57 return atBoundsCheck(0);
67 return atBoundsCheck(length - 1);
72 return at(length - 1);
75 virtual unsigned int append(
T*
elem);
77 virtual void swap(
unsigned int p1,
unsigned int p2);
82 virtual void deleteAt(
unsigned int pos);
84 virtual void deleteLast();
86 virtual int remove(
T*
elem);
88 virtual int lookup(
T*
elem)
const;
90 virtual int removeUnSwapped(
T*
elem);
93 virtual void destroy();
95 virtual void replace(
T*
elem,
unsigned int pos);
97 void reserve(
unsigned int init);
103 unsigned int capacity;
104 unsigned int BLOCKSIZE;
110 virtual void expand();
113 virtual unsigned int appendUnsafe(
T*
elem);
141 block =
new T*[capacity];
160 length = capacity = 0;
167 for (
unsigned int i = 0;
i < length; ++
i) {
181 for (
unsigned int i = 0;
i < length; ++
i) {
188 capacity += BLOCKSIZE;
196 if (length == capacity) {
199 block[length] =
elem;
209 if (length == capacity) {
212 block[length] =
elem;
242 if (pos != length - 1) {
243 swap(pos, length - 1);
254 block[length] =
nullptr;
263 for (
unsigned int i = 0;
i < length; ++
i) {
265 pos =
static_cast<int>(
i);
276 int pos = lookup(
elem);
278 deleteAt(
static_cast<unsigned int>(pos));
287 const int pos = lookup(
elem);
289 for (
unsigned int i =
static_cast<unsigned int>(pos);
i < length - 1; ++
i) {
290 block[
i] = block[
i + 1];
301 if (init <= capacity) {
306 for (
unsigned int i = 0;
i < length; ++
i) {
Dynamic templated vector.
unsigned int num() const
Returns the number of elements in the vector.
T * lastBoundsCheck() const
Returns the last element, and returns nullptr if out of range.
virtual void destroy()
Deletes all elements in the vector.
T * atBoundsCheck(unsigned int pos) const
Returns the element at the specified position, and returns nullptr when out of range.
T * firstBoundsCheck() const
Returns the first element, and return nullptr if out of range.
T * at(unsigned int pos) const
Returns the element at the specified position.
T * last() const
Returns the last element.
T * first() const
Returns the first element.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
void deleteVector(CSOObjectVector< T > *vector, bool deleteEntries=true)