MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
ml::CSOObjectVector< T > Class Template Reference

Dynamic templated vector. More...

#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.
 
T * atBoundsCheck (unsigned int pos) const
 Returns the element at the specified position, and returns nullptr when out of range.
 
T * at (unsigned int pos) const
 Returns the element at the specified position.
 
T * firstBoundsCheck () const
 Returns the first element, and return nullptr if out of range.
 
T * first () const
 Returns the first element.
 
T * lastBoundsCheck () const
 Returns the last element, and returns nullptr if out of range.
 
T * last () 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 ()
 Clears all internal pointers.
 
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 ()
 Deletes all elements in the vector.
 
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)
 Appends the element to back of vector.
 

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 30 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 134 of file CSOObjectVector.h.

References mlrange_cast(), and T.

◆ ~CSOObjectVector()

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

Standard destructor.

Definition at line 147 of file CSOObjectVector.h.

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 193 of file CSOObjectVector.h.

References mlrange_cast().

◆ 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 207 of file CSOObjectVector.h.

References mlrange_cast().

Referenced by 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 50 of file CSOObjectVector.h.

Referenced by ml::CSOObjectHeap< T >::remove(), 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 45 of file CSOObjectVector.h.

◆ 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 154 of file CSOObjectVector.h.

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

◆ deleteAt()

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

Deletes an element at the specified position.

Definition at line 240 of file CSOObjectVector.h.

◆ deleteLast()

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

Deletes the last element of the vector.

Definition at line 250 of file CSOObjectVector.h.

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

◆ 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 165 of file CSOObjectVector.h.

References mlrange_cast().

Referenced by ml::deleteVector().

◆ expand()

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

Grows vector by adding an extra block of size BLOCKSIZE.

Definition at line 176 of file CSOObjectVector.h.

References mlrange_cast(), and T.

◆ first()

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

Returns the first element.

Definition at line 60 of file CSOObjectVector.h.

◆ 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 55 of file CSOObjectVector.h.

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

◆ last()

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

Returns the last element.

Definition at line 70 of file CSOObjectVector.h.

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 65 of file CSOObjectVector.h.

◆ 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 260 of file CSOObjectVector.h.

References mlrange_cast().

◆ 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 274 of file CSOObjectVector.h.

References mlrange_cast().

◆ 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 285 of file CSOObjectVector.h.

References mlrange_cast().

◆ 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 mlrange_cast().

◆ 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 299 of file CSOObjectVector.h.

References mlrange_cast(), and T.

◆ 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 226 of file CSOObjectVector.h.

References mlrange_cast(), and T.

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


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