35 inline unsigned int num()
const {
return _length;}
37 inline T*
at(
unsigned int pos)
const {
return (pos < _length) ? _block[pos] :
nullptr; }
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);
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;
158 T*& pb1 = _block[p1];
159 T*& pb2 = _block[p2];
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 * first()
Returns the first element.
T * last()
Returns the last element.
const T * first() const
Returns the first element.
T * at(unsigned int pos) const
Returns the element at the given position, returns NULL if out of range.
const T * last() const
Returns the last element.
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().