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
 Return number of elements in the vector.
T * at (unsigned int pos) const
 Return element at given position, return NULL when out of range.
T * first ()
 Return first element.
const T * first () const
 Return first element.
T * last ()
 Return last element.
const T * last () const
 Return last element.
virtual unsigned int append (T *elem)
 Append element to back of vector.
virtual void swap (unsigned int p1, unsigned int p2)
 Swaps two elements in vector.
virtual void clear ()
 Clear all internal pointers.
virtual void deleteAt (unsigned int pos)
 Delete element at given position.
virtual void deleteLast ()
 Delete last element of vector.
virtual int remove (T *elem)
 Delete element given by its pointer, search element and delete.
virtual int lookup (T *elem) const
 Search for element in vector and return its position.
virtual int removeUnSwapped (T *elem)
 Delete element given by its pointer, search element and delete, keep order of elements!
virtual void destroy ()
 Delete all elements in the vector.
virtual void replace (T *elem, unsigned int pos)
 Replace the given position with the given element.
void reserve (unsigned int init)
 Reserve num elements, copy old ones if needed.

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 
) [inline]

Standard constructor.

< Deletes this vector.

Definition at line 112 of file WEMVector.h.

References ML_CHECK_NEW, ML_TRACE_IN_TIME_CRITICAL, and T.

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

Standard destructor.

Definition at line 131 of file WEMVector.h.

References ml::WEMVector< T >::clear(), and ML_TRACE_IN_TIME_CRITICAL.


Member Function Documentation

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

Append element to back of vector.

Reimplemented in ml::WEMContainer< T >.

Definition at line 184 of file WEMVector.h.

References ml::WEMVector< T >::expand(), and ML_TRACE_IN_TIME_CRITICAL.

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

template<class T>
unsigned int ml::WEMVector< T >::appendUnsafe ( T *  elem  )  [inline, 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 199 of file WEMVector.h.

References ml::WEMVector< T >::expand(), and ML_TRACE_IN_TIME_CRITICAL.

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

Return element at given position, return NULL when out of range.

Reimplemented in ml::WEMContainer< T >.

Definition at line 40 of file WEMVector.h.

Referenced by ml::WEMVector< T >::lookup(), and ml::WEMHeap< T >::sort().

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

Clear all internal pointers.

This does not delete the elements in the vector!!

Definition at line 141 of file WEMVector.h.

References ML_DELETE_ARRAY, and ML_TRACE_IN_TIME_CRITICAL.

Referenced by ml::WEMVector< T >::~WEMVector().

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

Delete element at given position.

Definition at line 239 of file WEMVector.h.

References ml::WEMVector< T >::deleteLast(), ML_TRACE_IN_TIME_CRITICAL, and ml::WEMVector< T >::swap().

Referenced by ml::WEMVector< T >::remove().

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

Delete last element of vector.

Definition at line 250 of file WEMVector.h.

References ML_TRACE_IN_TIME_CRITICAL.

Referenced by ml::WEMVector< T >::deleteAt(), and ml::WEMVector< T >::removeUnSwapped().

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

Delete all elements in the vector.

This does not reset the number of elements!!

Reimplemented in ml::WEMContainer< T >.

Definition at line 154 of file WEMVector.h.

References ML_DELETE, and ML_TRACE_IN_TIME_CRITICAL.

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

Grow vector, add extra block of size BLOCKSIZE.

Definition at line 167 of file WEMVector.h.

References ML_CHECK_NEW, ML_DELETE_ARRAY, ML_TRACE_IN_TIME_CRITICAL, and T.

Referenced by ml::WEMVector< T >::append(), and ml::WEMVector< T >::appendUnsafe().

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

Return 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]

Return first element.

Definition at line 42 of file WEMVector.h.

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

Return last element.

Definition at line 48 of file WEMVector.h.

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

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

Return last element.

Definition at line 46 of file WEMVector.h.

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

Search for element in vector and return its position.

Definition at line 260 of file WEMVector.h.

References ml::WEMVector< T >::at(), and ML_TRACE_IN_TIME_CRITICAL.

Referenced by ml::WEMVector< T >::remove(), and ml::WEMVector< T >::removeUnSwapped().

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

Return number of elements in the 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  )  [inline, virtual]

Delete element given by its pointer, search element and delete.

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

Definition at line 277 of file WEMVector.h.

References ml::WEMVector< T >::deleteAt(), ml::WEMVector< T >::lookup(), and ML_TRACE_IN_TIME_CRITICAL.

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

Delete element given by its pointer, search element and delete, keep order of elements!

Definition at line 289 of file WEMVector.h.

References ml::WEMVector< T >::deleteLast(), ml::WEMVector< T >::lookup(), and ML_TRACE_IN_TIME_CRITICAL.

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

Replace the given position with the given element.

Reimplemented in ml::WEMContainer< T >.

Definition at line 212 of file WEMVector.h.

References ML_TRACE_IN_TIME_CRITICAL.

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

Reserve num elements, copy old ones if needed.

Definition at line 306 of file WEMVector.h.

References ML_CHECK_NEW, ML_DELETE_ARRAY, ML_TRACE_IN_TIME_CRITICAL, and T.

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

Swaps two elements in vector.

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

Definition at line 222 of file WEMVector.h.

References ML_TRACE_IN_TIME_CRITICAL, and T.

Referenced by ml::WEMVector< T >::deleteAt().


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

Generated on Sat Sep 3 18:39:41 2011 for MeVisLab Toolbox Reference by  doxygen 1.5.8