MeVisLab Toolbox Reference
|
Dynamic templated vector. More...
#include <WEMVector.h>
Public Member Functions | |
WEMVector (unsigned int init=0) | |
Standard constructor. | |
WEMVector (WEMVector &&other) noexcept | |
WEMVector & | operator= (WEMVector &&other) noexcept |
virtual | ~WEMVector () |
Standard destructor. | |
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 or returns NULL if out of range. | |
T * | first () |
Returns the first element. | |
const T * | first () const |
Returns the first element. | |
T * | last () |
Returns the last element. | |
const T * | last () const |
Returns the last element. | |
virtual unsigned int | append (T *elem) |
Appends the given element to back of this vector. | |
virtual void | swap (unsigned int p1, unsigned int p2) |
Swaps the two elements given by their indices in this vector. | |
virtual void | clear () |
Clears all internal pointers. | |
virtual void | deleteAt (unsigned int pos) |
Deletes the element at the given position. | |
virtual void | deleteLast () |
Deletes the last element of this vector. | |
virtual int | remove (T *elem) |
Deletes the element given by its pointer. | |
virtual int | lookup (T *elem) const |
Searches for the given element in this vector and returns its position. | |
virtual int | removeUnSwapped (T *elem) |
Deletes the element given by its pointer. Keeps the order of the elements! | |
virtual void | destroy () |
Deletes all elements in this vector. | |
virtual void | replace (T *elem, unsigned int pos) |
Replaces the given position with the given element. | |
void | reserve (unsigned int init) |
Reserves init elements, copies old ones if existing. | |
Protected Member Functions | |
virtual void | expand () |
Grow vector, add extra block of size BLOCKSIZE. | |
virtual unsigned int | appendUnsafe (T *elem) |
Append element to back of vector, don't check on element being non-NULL. | |
Dynamic templated vector.
For speed and better memory handling, the vector is an array within an array. This allows for quick expanding. An initial internal buffer with 32 pointers avoids an allocation on small vectors.
Definition at line 27 of file WEMVector.h.
ml::WEMVector< T, fixedBufferSize >::WEMVector | ( | unsigned int | init = 0 | ) |
|
noexcept |
Definition at line 111 of file WEMVector.h.
References mlrange_cast().
|
virtual |
Standard destructor.
Definition at line 144 of file WEMVector.h.
|
virtual |
Appends the given element to back of this vector.
Definition at line 188 of file WEMVector.h.
References mlrange_cast().
|
protectedvirtual |
Append element to back of vector, don't check on element being non-NULL.
Don't use this function directly!!
Definition at line 205 of file WEMVector.h.
References mlrange_cast().
Referenced by ml::WEMHeap< T >::insert(), and ml::WEMHeap< T >::insert().
|
inline |
Returns the element at the given position or returns NULL if out of range.
Definition at line 41 of file WEMVector.h.
|
virtual |
Clears all internal pointers.
This does not delete the elements in the vector!
Reimplemented in ml::WEMHeap< T >.
Definition at line 152 of file WEMVector.h.
References mlrange_cast().
Referenced by ml::WEMHeap< T >::clear().
|
virtual |
Deletes the element at the given position.
Definition at line 243 of file WEMVector.h.
|
virtual |
Deletes the last element of this vector.
Definition at line 255 of file WEMVector.h.
|
virtual |
Deletes all elements in this vector.
This does not reset the number of elements!!
Reimplemented in ml::WEMContainer< T >.
Definition at line 168 of file WEMVector.h.
References mlrange_cast().
|
protectedvirtual |
Grow vector, add extra block of size BLOCKSIZE.
Definition at line 180 of file WEMVector.h.
|
inline |
Returns the first element.
Definition at line 43 of file WEMVector.h.
Referenced by ml::WEMHeap< T >::root().
|
inline |
Returns the first element.
Definition at line 45 of file WEMVector.h.
References ml::WEMVector< T, fixedBufferSize >::first().
Referenced by ml::WEMVector< T, fixedBufferSize >::first().
|
inline |
Returns the last element.
Definition at line 47 of file WEMVector.h.
|
inline |
Returns the last element.
Definition at line 49 of file WEMVector.h.
References ml::WEMVector< T, fixedBufferSize >::last().
Referenced by ml::WEMVector< T, fixedBufferSize >::last().
|
virtual |
Searches for the given element in this vector and returns its position.
Definition at line 266 of file WEMVector.h.
References mlrange_cast().
|
inline |
Returns the number of elements in this vector.
Definition at line 39 of file WEMVector.h.
|
noexcept |
Definition at line 117 of file WEMVector.h.
References mlrange_cast().
|
virtual |
Deletes the element given by its pointer.
Definition at line 283 of file WEMVector.h.
References mlrange_cast().
|
virtual |
Deletes the element given by its pointer. Keeps the order of the elements!
Definition at line 296 of file WEMVector.h.
References mlrange_cast().
|
virtual |
Replaces the given position with the given element.
Definition at line 219 of file WEMVector.h.
References mlrange_cast().
void ml::WEMVector< T, fixedBufferSize >::reserve | ( | unsigned int | init | ) |
Reserves init
elements, copies old ones if existing.
Definition at line 313 of file WEMVector.h.
References mlrange_cast(), and T.
|
virtual |
Swaps the two elements given by their indices in this vector.
Reimplemented in ml::WEMContainer< T >, and ml::WEMHeap< T >.
Definition at line 227 of file WEMVector.h.
References mlrange_cast(), and T.
Referenced by ml::WEMHeap< T >::swap().