MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
ml::WEMVector< T, fixedBufferSize > Class Template 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 set (unsigned int pos, T *elem)
 Sets the given element at the given position.
 
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.
 
void resize (unsigned int newSize)
 Resizes the vector to the given number of elements.
 

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, unsigned 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 26 of file WEMVector.h.

Constructor & Destructor Documentation

◆ WEMVector() [1/2]

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

Standard constructor.

Definition at line 119 of file WEMVector.h.

References mlrange_cast(), and T.

◆ WEMVector() [2/2]

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

Definition at line 131 of file WEMVector.h.

References mlrange_cast().

◆ ~WEMVector()

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

Standard destructor.

Definition at line 160 of file WEMVector.h.

Member Function Documentation

◆ append()

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

Appends the given element to back of this vector.

Definition at line 199 of file WEMVector.h.

References mlrange_cast().

◆ appendUnsafe()

template<class T , unsigned 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 220 of file WEMVector.h.

References mlrange_cast().

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

◆ at()

template<class T , unsigned 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 42 of file WEMVector.h.

◆ clear()

template<class T , unsigned 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 167 of file WEMVector.h.

References mlrange_cast().

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

◆ deleteAt()

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

Deletes the element at the given position.

Definition at line 254 of file WEMVector.h.

◆ deleteLast()

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

Deletes the last element of this vector.

Definition at line 264 of file WEMVector.h.

◆ destroy()

template<class T , unsigned 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 181 of file WEMVector.h.

References mlrange_cast().

◆ expand()

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

Grow vector, add extra block of size BLOCKSIZE.

Definition at line 192 of file WEMVector.h.

◆ first() [1/2]

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

Returns the first element.

Definition at line 47 of file WEMVector.h.

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

◆ first() [2/2]

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

Returns the first element.

Definition at line 52 of file WEMVector.h.

◆ last() [1/2]

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

Returns the last element.

Definition at line 57 of file WEMVector.h.

◆ last() [2/2]

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

Returns the last element.

Definition at line 62 of file WEMVector.h.

◆ lookup()

template<class T , unsigned 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 273 of file WEMVector.h.

References mlrange_cast().

◆ num()

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

Returns the number of elements in this vector.

Definition at line 37 of file WEMVector.h.

◆ operator=()

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

Definition at line 137 of file WEMVector.h.

References mlrange_cast().

◆ remove()

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

Deletes the element given by its pointer.

Definition at line 287 of file WEMVector.h.

References mlrange_cast().

◆ removeUnSwapped()

template<class T , unsigned 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 298 of file WEMVector.h.

References mlrange_cast().

◆ replace()

template<class T , unsigned 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 232 of file WEMVector.h.

References mlrange_cast().

◆ reserve()

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

Reserves init elements; copies old ones if existing.

Definition at line 312 of file WEMVector.h.

References mlrange_cast(), and T.

◆ resize()

template<class T , unsigned int fixedBufferSize = 32>
void ml::WEMVector< T, fixedBufferSize >::resize ( unsigned int newSize)
inline

Resizes the vector to the given number of elements.

Definition at line 93 of file WEMVector.h.

References mlrange_cast().

◆ set()

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

Sets the given element at the given position.

Definition at line 213 of file WEMVector.h.

References mlrange_cast().

◆ swap()

template<class T , unsigned 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 240 of file WEMVector.h.

References mlrange_cast(), and T.

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


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