MeVisLab Toolbox Reference
ml::CSOObjectVector< T > Class Template Reference

#include <CSOObjectVector.h>

Inheritance diagram for ml::CSOObjectVector< T >:
ml::CSOObjectHeap< T >

Public Member Functions

 CSOObjectVector (unsigned int init=0, unsigned int bs=65535)
 Standard constructor.
virtual ~CSOObjectVector ()
 Standard destructor.
unsigned int num () const
 Returns the number of elements in the vector.
TatBoundsCheck (unsigned int pos) const
 Returns the element at the specified position, and returns nullptr when out of range.
Tat (unsigned int pos) const
 Returns the element at the specified position.
TfirstBoundsCheck () const
 Returns the first element, and return nullptr if out of range.
Tfirst () const
 Returns the first element.
TlastBoundsCheck () const
 Returns the last element, and returns nullptr if out of range.
Tlast () const
 Returns the last element.
virtual unsigned int append (T *elem)
 Appends the element to the back of the vector and returns its position.
virtual void swap (unsigned int p1, unsigned int p2)
 Swaps two elements in the vector.
virtual void clear ()
virtual void deleteAt (unsigned int pos)
 Deletes an element at the specified position.
virtual void deleteLast ()
 Deletes the last element of the vector.
virtual int remove (T *elem)
 Deletes an element specified by its pointer and returns its position.
virtual int lookup (T *elem) const
 Searches for an element in the vector and returns its position.
virtual int removeUnSwapped (T *elem)
 Deletes an element specified by its pointer and returns its position.
virtual void destroy ()
virtual void replace (T *elem, unsigned int pos)
 Replaces the element at the specified position with the specified element.
void reserve (unsigned int init)
 Reserves a number of elements. It copies old elements if needed.

Protected Member Functions

virtual void expand ()
 Grows vector by adding an extra block of size BLOCKSIZE.
virtual unsigned int appendUnsafe (T *elem)

Detailed Description

template<class T>
class ml::CSOObjectVector< 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 65535. This allows for quick expanding.

Definition at line 31 of file CSOObjectVector.h.

Constructor & Destructor Documentation

◆ CSOObjectVector()

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

Standard constructor.

Definition at line 121 of file CSOObjectVector.h.

References CSOObjectVector(), and T.

Referenced by ml::CSOObjectHeap< T >::CSOObjectHeap(), CSOObjectVector(), and ml::CSOObjectHeap< T >::sort().

◆ ~CSOObjectVector()

template<class T>
ml::CSOObjectVector< T >::~CSOObjectVector ( )
virtual

Standard destructor.

Definition at line 136 of file CSOObjectVector.h.

References clear(), and ~CSOObjectVector().

Referenced by ~CSOObjectVector().

Member Function Documentation

◆ append()

template<class T>
unsigned int ml::CSOObjectVector< T >::append ( T * elem)
virtual

Appends the element to the back of the vector and returns its position.

Definition at line 188 of file CSOObjectVector.h.

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

Referenced by append(), and ml::CSOObjectHeap< T >::sort().

◆ appendUnsafe()

template<class T>
unsigned int ml::CSOObjectVector< T >::appendUnsafe ( T * elem)
protectedvirtual

Appends the element to back of vector. It does not check whether the element is not nullptr. Do not use this method directly!

Definition at line 205 of file CSOObjectVector.h.

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

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

◆ at()

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

Returns the element at the specified position.

Definition at line 46 of file CSOObjectVector.h.

References T.

Referenced by first(), last(), lookup(), ml::CSOObjectHeap< T >::remove(), ml::CSOObjectHeap< T >::sort(), and ml::CSOObjectHeap< T >::swap().

◆ atBoundsCheck()

template<class T>
T * ml::CSOObjectVector< T >::atBoundsCheck ( unsigned int pos) const
inline

Returns the element at the specified position, and returns nullptr when out of range.

Definition at line 44 of file CSOObjectVector.h.

References T.

Referenced by firstBoundsCheck(), and lastBoundsCheck().

◆ clear()

template<class T>
void ml::CSOObjectVector< T >::clear ( )
virtual

Clears all internal pointers. This does not delete the elements in the vector!

Definition at line 144 of file CSOObjectVector.h.

References clear().

Referenced by clear(), ml::CSOObjectHeap< T >::sort(), ml::CSOObjectHeap< T >::~CSOObjectHeap(), and ~CSOObjectVector().

◆ deleteAt()

template<class T>
void ml::CSOObjectVector< T >::deleteAt ( unsigned int pos)
virtual

Deletes an element at the specified position.

Definition at line 243 of file CSOObjectVector.h.

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

Referenced by deleteAt(), and remove().

◆ deleteLast()

template<class T>
void ml::CSOObjectVector< T >::deleteLast ( )
virtual

Deletes the last element of the vector.

Definition at line 255 of file CSOObjectVector.h.

References deleteLast().

Referenced by deleteAt(), deleteLast(), ml::CSOObjectHeap< T >::remove(), and removeUnSwapped().

◆ destroy()

template<class T>
void ml::CSOObjectVector< T >::destroy ( )
virtual

Deletes all elements in the vector. This does not reset the number of elements!

Definition at line 157 of file CSOObjectVector.h.

References destroy().

Referenced by ml::deleteVector(), and destroy().

◆ expand()

template<class T>
void ml::CSOObjectVector< T >::expand ( )
protectedvirtual

Grows vector by adding an extra block of size BLOCKSIZE.

Definition at line 169 of file CSOObjectVector.h.

References expand(), and T.

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

◆ first()

template<class T>
T * ml::CSOObjectVector< T >::first ( ) const
inline

Returns the first element.

Definition at line 50 of file CSOObjectVector.h.

References at(), and T.

◆ firstBoundsCheck()

template<class T>
T * ml::CSOObjectVector< T >::firstBoundsCheck ( ) const
inline

Returns the first element, and return nullptr if out of range.

Definition at line 48 of file CSOObjectVector.h.

References atBoundsCheck(), and T.

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

◆ last()

template<class T>
T * ml::CSOObjectVector< T >::last ( ) const
inline

Returns the last element.

Definition at line 54 of file CSOObjectVector.h.

References at(), and T.

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

◆ lastBoundsCheck()

template<class T>
T * ml::CSOObjectVector< T >::lastBoundsCheck ( ) const
inline

Returns the last element, and returns nullptr if out of range.

Definition at line 52 of file CSOObjectVector.h.

References atBoundsCheck(), and T.

◆ lookup()

template<class T>
int ml::CSOObjectVector< T >::lookup ( T * elem) const
virtual

Searches for an element in the vector and returns its position.

Definition at line 267 of file CSOObjectVector.h.

References at(), lookup(), and T.

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

◆ num()

template<class T>
unsigned int ml::CSOObjectVector< T >::num ( ) const
inline

◆ remove()

template<class T>
int ml::CSOObjectVector< T >::remove ( T * elem)
virtual

Deletes an element specified by its pointer and returns its position.

Reimplemented in ml::CSOObjectHeap< T >.

Definition at line 284 of file CSOObjectVector.h.

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

Referenced by remove().

◆ removeUnSwapped()

template<class T>
int ml::CSOObjectVector< T >::removeUnSwapped ( T * elem)
virtual

Deletes an element specified by its pointer and returns its position.

Definition at line 297 of file CSOObjectVector.h.

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

Referenced by removeUnSwapped().

◆ replace()

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

Replaces the element at the specified position with the specified element.

Definition at line 219 of file CSOObjectVector.h.

References replace(), and T.

Referenced by replace().

◆ reserve()

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

Reserves a number of elements. It copies old elements if needed.

Definition at line 314 of file CSOObjectVector.h.

References reserve(), and T.

Referenced by reserve().

◆ swap()

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

Swaps two elements in the vector.

Reimplemented in ml::CSOObjectHeap< T >.

Definition at line 227 of file CSOObjectVector.h.

References swap(), and T.

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


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