MeVisLab Toolbox Reference
ml::WEMVector< T, fixedBufferSize > Class Template Reference

Dynamic templated vector. More...

#include <WEMVector.h>

Public Member Functions

 WEMVector (unsigned int init=0)
 Standard constructor. More...
 
 WEMVector (WEMVector &&other) noexcept
 
WEMVectoroperator= (WEMVector &&other) noexcept
 
virtual ~WEMVector ()
 Standard destructor. More...
 
unsigned int num () const
 Returns the number of elements in this vector. More...
 
Tat (unsigned int pos) const
 Returns the element at the given position or returns NULL if out of range. More...
 
Tfirst ()
 Returns the first element. More...
 
const Tfirst () const
 Returns the first element. More...
 
Tlast ()
 Returns the last element. More...
 
const Tlast () const
 Returns the last element. More...
 
virtual unsigned int append (T *elem)
 Appends the given element to back of this vector. More...
 
virtual void swap (unsigned int p1, unsigned int p2)
 Swaps the two elements given by their indices in this vector. More...
 
virtual void clear ()
 Clears all internal pointers. More...
 
virtual void deleteAt (unsigned int pos)
 Deletes the element at the given position. More...
 
virtual void deleteLast ()
 Deletes the last element of this vector. More...
 
virtual int remove (T *elem)
 Deletes the element given by its pointer. More...
 
virtual int lookup (T *elem) const
 Searches for the given element in this vector and returns its position. More...
 
virtual int removeUnSwapped (T *elem)
 Deletes the element given by its pointer. Keeps the order of the elements! More...
 
virtual void destroy ()
 Deletes all elements in this vector. More...
 
virtual void replace (T *elem, unsigned int pos)
 Replaces the given position with the given element. More...
 
void reserve (unsigned int init)
 Reserves init elements, copies old ones if existing. More...
 

Protected Member Functions

virtual void expand ()
 Grow vector, add extra block of size BLOCKSIZE. More...
 
virtual unsigned int appendUnsafe (T *elem)
 Append element to back of vector, don't check on element being non-NULL. More...
 

Detailed Description

template<class T, int fixedBufferSize = 32>
class ml::WEMVector< T, fixedBufferSize >

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.

Constructor & Destructor Documentation

◆ WEMVector() [1/2]

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

Standard constructor.

Definition at line 98 of file WEMVector.h.

References ml::library::init(), and T.

◆ WEMVector() [2/2]

template<class T , int fixedBufferSize>
ml::WEMVector< T, fixedBufferSize >::WEMVector ( WEMVector< T, fixedBufferSize > &&  other)
noexcept

Definition at line 111 of file WEMVector.h.

◆ ~WEMVector()

template<class T , int fixedBufferSize>
ml::WEMVector< T, fixedBufferSize >::~WEMVector
virtual

Standard destructor.

Definition at line 144 of file WEMVector.h.

Member Function Documentation

◆ append()

template<class T , int fixedBufferSize>
unsigned int ml::WEMVector< T, fixedBufferSize >::append ( T elem)
virtual

Appends the given element to back of this vector.

Definition at line 188 of file WEMVector.h.

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

◆ appendUnsafe()

template<class T , int fixedBufferSize>
unsigned int ml::WEMVector< T, fixedBufferSize >::appendUnsafe ( T elem)
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.

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

◆ at()

template<class T , int fixedBufferSize = 32>
T* ml::WEMVector< T, fixedBufferSize >::at ( unsigned int  pos) const
inline

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

Definition at line 41 of file WEMVector.h.

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

◆ clear()

template<class T , int fixedBufferSize>
void ml::WEMVector< T, fixedBufferSize >::clear ( void  )
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.

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

◆ deleteAt()

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

Deletes the element at the given position.

Definition at line 243 of file WEMVector.h.

◆ deleteLast()

template<class T , int fixedBufferSize>
void ml::WEMVector< T, fixedBufferSize >::deleteLast
virtual

Deletes the last element of this vector.

Definition at line 255 of file WEMVector.h.

◆ destroy()

template<class T , int fixedBufferSize>
void ml::WEMVector< T, fixedBufferSize >::destroy
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.

◆ expand()

template<class T , int fixedBufferSize>
void ml::WEMVector< T, fixedBufferSize >::expand
protectedvirtual

Grow vector, add extra block of size BLOCKSIZE.

Definition at line 180 of file WEMVector.h.

◆ first() [1/2]

template<class T , int fixedBufferSize = 32>
T* ml::WEMVector< T, fixedBufferSize >::first ( )
inline

Returns the first element.

Definition at line 43 of file WEMVector.h.

References boost::at().

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

◆ first() [2/2]

template<class T , int fixedBufferSize = 32>
const T* ml::WEMVector< T, fixedBufferSize >::first ( ) const
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().

◆ last() [1/2]

template<class T , int fixedBufferSize = 32>
T* ml::WEMVector< T, fixedBufferSize >::last ( )
inline

Returns the last element.

Definition at line 47 of file WEMVector.h.

References boost::at().

◆ last() [2/2]

template<class T , int fixedBufferSize = 32>
const T* ml::WEMVector< T, fixedBufferSize >::last ( ) const
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().

◆ lookup()

template<class T , int fixedBufferSize>
int ml::WEMVector< T, fixedBufferSize >::lookup ( T elem) const
virtual

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

Definition at line 266 of file WEMVector.h.

◆ num()

template<class T , int fixedBufferSize = 32>
unsigned int ml::WEMVector< T, fixedBufferSize >::num ( ) const
inline

Returns the number of elements in this vector.

Definition at line 39 of file WEMVector.h.

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

◆ operator=()

template<class T , int fixedBufferSize>
WEMVector< T, fixedBufferSize > & ml::WEMVector< T, fixedBufferSize >::operator= ( WEMVector< T, fixedBufferSize > &&  other)
noexcept

Definition at line 117 of file WEMVector.h.

◆ remove()

template<class T , int fixedBufferSize>
int ml::WEMVector< T, fixedBufferSize >::remove ( T elem)
virtual

Deletes the element given by its pointer.

Definition at line 283 of file WEMVector.h.

◆ removeUnSwapped()

template<class T , int fixedBufferSize>
int ml::WEMVector< T, fixedBufferSize >::removeUnSwapped ( T elem)
virtual

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

Definition at line 296 of file WEMVector.h.

◆ replace()

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

Replaces the given position with the given element.

Definition at line 219 of file WEMVector.h.

◆ reserve()

template<class T , int fixedBufferSize>
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 ml::library::init(), and T.

◆ swap()

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

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

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

Definition at line 227 of file WEMVector.h.

References T.

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


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