MeVisLabToolboxReference
ml::WEMVector< T > Class Template Reference

Dynamic templated vector. More...

#include <WEMVector.h>

List of all members.

Public Member Functions

 WEMVector (unsigned int init=0, unsigned int bs=8192)
 Standard constructor.
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.

Detailed Description

template<class T>
class ml::WEMVector< T >

Dynamic templated vector.

For speed and better memory handling, the vector is an array within an array. The base blocks have a BLOCKSIZE of 8192 This allows for quick expanding.

Definition at line 29 of file WEMVector.h.


Constructor & Destructor Documentation

template<class T >
ml::WEMVector< T >::WEMVector ( unsigned int  init = 0,
unsigned int  bs = 8192 
)

Standard constructor.

Definition at line 97 of file WEMVector.h.

References ML_CHECK_NEW, and T.

template<class T >
ml::WEMVector< T >::~WEMVector ( ) [virtual]

Standard destructor.

Definition at line 116 of file WEMVector.h.


Member Function Documentation

template<class T>
unsigned int ml::WEMVector< T >::append ( T *  elem) [virtual]

Appends the given element to back of this vector.

Reimplemented in ml::WEMContainer< T >.

Definition at line 166 of file WEMVector.h.

Referenced by ml::WEMHeap< T >::sort().

template<class T>
unsigned int ml::WEMVector< T >::appendUnsafe ( T *  elem) [protected, virtual]

Append element to back of vector, don't check on element being non-NULL.

Don't use this function directly!!

Definition at line 183 of file WEMVector.h.

Referenced by ml::WEMContainer< T >::append(), and ml::WEMHeap< T >::insert().

template<class T>
T* ml::WEMVector< T >::at ( unsigned int  pos) const [inline]

Returns the element at the given position or returns NULL if out of range.

Reimplemented in ml::WEMContainer< T >.

Definition at line 40 of file WEMVector.h.

Referenced by ml::WEMContainer< T >::at(), and ml::WEMHeap< T >::sort().

template<class T >
void ml::WEMVector< T >::clear ( void  ) [virtual]

Clears all internal pointers.

This does not delete the elements in the vector!

Definition at line 124 of file WEMVector.h.

References ML_DELETE_ARRAY.

template<class T >
void ml::WEMVector< T >::deleteAt ( unsigned int  pos) [virtual]

Deletes the element at the given position.

Definition at line 221 of file WEMVector.h.

template<class T >
void ml::WEMVector< T >::deleteLast ( ) [virtual]

Deletes the last element of this vector.

Definition at line 233 of file WEMVector.h.

template<class T >
void ml::WEMVector< T >::destroy ( ) [virtual]

Deletes all elements in this vector.

This does not reset the number of elements!!

Reimplemented in ml::WEMContainer< T >.

Definition at line 136 of file WEMVector.h.

References ML_DELETE.

template<class T >
void ml::WEMVector< T >::expand ( ) [protected, virtual]

Grow vector, add extra block of size BLOCKSIZE.

Definition at line 148 of file WEMVector.h.

References ML_CHECK_NEW, ML_DELETE_ARRAY, and T.

template<class T>
const T* ml::WEMVector< T >::first ( ) const [inline]

Returns the first element.

Definition at line 44 of file WEMVector.h.

Referenced by ml::WEMVector< WEMPrimitive >::first().

template<class T>
T* ml::WEMVector< T >::first ( ) [inline]

Returns the first element.

Definition at line 42 of file WEMVector.h.

Referenced by ml::WEMHeap< T >::root().

template<class T>
T* ml::WEMVector< T >::last ( ) [inline]

Returns the last element.

Definition at line 46 of file WEMVector.h.

template<class T>
const T* ml::WEMVector< T >::last ( ) const [inline]

Returns the last element.

Definition at line 48 of file WEMVector.h.

Referenced by ml::WEMVector< WEMPrimitive >::last().

template<class T>
int ml::WEMVector< T >::lookup ( T *  elem) const [virtual]

Searches for the given element in this vector and returns its position.

Definition at line 244 of file WEMVector.h.

template<class T>
unsigned int ml::WEMVector< T >::num ( ) const [inline]

Returns the number of elements in this vector.

Definition at line 38 of file WEMVector.h.

Referenced by ml::WEMHeap< T >::sort().

template<class T>
int ml::WEMVector< T >::remove ( T *  elem) [virtual]

Deletes the element given by its pointer.

Reimplemented in ml::WEMContainer< T >, and ml::WEMHeap< T >.

Definition at line 261 of file WEMVector.h.

template<class T>
int ml::WEMVector< T >::removeUnSwapped ( T *  elem) [virtual]

Deletes the element given by its pointer. Keeps the order of the elements!

Definition at line 274 of file WEMVector.h.

template<class T>
void ml::WEMVector< T >::replace ( T *  elem,
unsigned int  pos 
) [virtual]

Replaces the given position with the given element.

Reimplemented in ml::WEMContainer< T >.

Definition at line 197 of file WEMVector.h.

Referenced by ml::WEMContainer< T >::destroy(), and ml::WEMContainer< T >::replace().

template<class T >
void ml::WEMVector< T >::reserve ( unsigned int  init)

Reserves init elements, copies old ones if existing.

Definition at line 291 of file WEMVector.h.

References ML_CHECK_NEW, ML_DELETE_ARRAY, and T.

template<class T >
void ml::WEMVector< T >::swap ( unsigned int  p1,
unsigned int  p2 
) [virtual]

Swaps the two elements given by their indices in this vector.

Reimplemented in ml::WEMContainer< T >, and ml::WEMHeap< T >.

Definition at line 205 of file WEMVector.h.

References T.

Referenced by ml::WEMHeap< T >::swap(), and ml::WEMContainer< T >::swap().


The documentation for this class was generated from the following file: