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

#include <WEMVector.h>

Public Member Functions

 WEMVector (unsigned int init=0)
 Standard constructor.
 WEMVector (WEMVector &&other) noexcept
WEMVectoroperator= (WEMVector &&other) noexcept
virtual ~WEMVector ()
 Standard destructor.
unsigned int num () const
 Returns the number of elements in this vector.
Tat (unsigned int pos) const
 Returns the element at the given position or returns NULL if out of range.
Tfirst ()
 Returns the first element.
const Tfirst () const
 Returns the first element.
Tlast ()
 Returns the last element.
const Tlast () 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 ()
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 ()
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)

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 T, and WEMVector().

Referenced by operator=(), WEMVector(), and WEMVector().

◆ 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.

References WEMVector().

◆ ~WEMVector()

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

Standard destructor.

Definition at line 144 of file WEMVector.h.

References clear(), and ~WEMVector().

Referenced by ~WEMVector().

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.

References append(), expand(), and T.

Referenced by append(), and 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.

References appendUnsafe(), expand(), and T.

Referenced by ml::WEMContainer< T >::append(), appendUnsafe(), ml::WEMHeap< T >::insert(), and 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.

References T.

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

◆ clear()

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

Referenced by ml::WEMHeap< T >::clear(), clear(), and ~WEMVector().

◆ 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.

References deleteAt(), deleteLast(), and swap().

Referenced by deleteAt(), and remove().

◆ 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.

References deleteLast().

Referenced by deleteAt(), deleteLast(), and removeUnSwapped().

◆ 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.

References destroy().

Referenced by destroy().

◆ 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.

References expand(), and reserve().

Referenced by append(), appendUnsafe(), and expand().

◆ 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 at(), and T.

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 first(), and T.

Referenced by 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 at(), and T.

◆ 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 last(), and T.

Referenced by 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.

References lookup(), and T.

Referenced by lookup(), remove(), and removeUnSwapped().

◆ 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.

References operator=(), and WEMVector().

Referenced by operator=().

◆ 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.

References deleteAt(), lookup(), remove(), and T.

Referenced by remove().

◆ 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.

References deleteLast(), lookup(), removeUnSwapped(), and T.

Referenced by removeUnSwapped().

◆ 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.

References replace(), and T.

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

◆ 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 reserve(), and T.

Referenced by expand(), and reserve().

◆ 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::WEMContainer< T >, and ml::WEMHeap< T >.

Definition at line 227 of file WEMVector.h.

References swap(), and T.

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


The documentation for this class was generated from the following file:
  • MeVisLab/Standard/Sources/ML/MLWEM/WEMDataStructure/WEMVector.h