35 inline unsigned int num()
const {
return _length;}
37 inline T*
at(
unsigned int pos)
const {
return (pos < _length) ? _block[pos] :
nullptr; }
41 inline const T*
first()
const {
return at(0);}
43 inline T*
last() {
return at(_length - 1);}
45 inline const T*
last()
const {
return at(_length - 1);}
47 virtual unsigned int append(
T*
elem);
49 virtual void swap(
unsigned int p1,
unsigned int p2);
54 virtual void destroy();
56 virtual void deleteAt(
unsigned int pos);
58 virtual void deleteLast();
60 virtual int remove(
T*
elem);
62 virtual int lookup(
T*
elem)
const;
65 virtual int removeUnSwapped(
T*
elem);
67 virtual void replace(
T*
elem,
unsigned int pos);
74 unsigned int _capacity;
87 _block =
new T*[init];
89 for (
unsigned int i = 0;
i < init;
i ++)
119 for (
unsigned int i = 0;
i < _capacity;
i ++)
121 delete _block[
i]; _block[
i] =
nullptr;
133 if (_length < _capacity)
135 _block[_length] =
elem;
171 if (pos >= _length) {
return; }
173 if (pos != _length - 1)
175 swap(pos, _length - 1);
185 if (_length > 0) { _length --; }
194 for (
unsigned int i = 0;
i < _length;
i ++)
210 int pos = lookup(
elem);
223 int pos = lookup(
elem);
226 for (
unsigned int i = pos;
i < _length - 1;
i ++)
228 _block[
i] = _block[
i + 1];
Dynamic templated vector.
unsigned int num() const
Returns the number of elements in this vector.
T * at(unsigned int pos) const
Returns the element at the given position, returns NULL if out of range.
T * last()
Returns the last element.
T * first()
Returns the first element.
const T * first() const
Returns the first element.
const T * last() const
Returns the last element.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.