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

Heap structure with property i>2*i+1 and i>2*i+2 Parent i has children 2*i+1 and 2*i+2 Smallest values are stored closer to root of tree Elements are sorted while inserting them in the heap. More...

#include <CSOObjectHeap.h>

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

Public Member Functions

 CSOObjectHeap ()
 Standard constructor.
 
 ~CSOObjectHeap () override
 Standard destructor.
 
Troot () const
 Get root (first) element of heap, typecast from CSOLiveWireNode to T.
 
void swap (unsigned int i, unsigned int j) override
 Swap two heap elements and resort heap.
 
void insert (T *we)
 Insert heap element, resort heap.
 
void insert (T *we, float v)
 Insert heap element and set value, resort heap.
 
void update (T *we, float nv)
 Update given heap element with new value, resort heap.
 
int remove (T *we) override
 Remove heap element, resort heap.
 
void sort ()
 Sort heap.
 
- Public Member Functions inherited from ml::CSOObjectVector< T >
 CSOObjectVector (unsigned int init=0, unsigned int bs=65535)
 Standard constructor.
 
virtual ~CSOObjectVector ()
 Standard destructor.
 
unsigned int num () const
 Returns number of elements in the vector.
 
TatBoundsCheck (unsigned int pos) const
 Returns element at given position, return NULL when out of range.
 
Tat (unsigned int pos) const
 Returns element at given position.
 
TfirstBoundsCheck () const
 Returns first element, return NULL when out of range.
 
Tfirst () const
 Returns first element.
 
TlastBoundsCheck () const
 Returns last element, return NULL when out of range.
 
Tlast () const
 Returns last element.
 
virtual unsigned int append (T *elem)
 Appends element to back of vector.
 
virtual void clear ()
 Clears all internal pointers This does not delete the elements in the vector!!
 
virtual void deleteAt (unsigned int pos)
 Deletes element at given position.
 
virtual void deleteLast ()
 Deletes last element of vector.
 
virtual int lookup (T *elem) const
 Searches for element in vector and return its position.
 
virtual int removeUnSwapped (T *elem)
 Deletes element given by its pointer, search element and delete, keep order of elements!
 
virtual void destroy ()
 Deletes all elements in the vector This does not reset the number of elements!!
 
virtual void replace (T *elem, unsigned int pos)
 Replaces the given position with the given element.
 
void reserve (unsigned int init)
 Reserves num elements, copy old ones if needed.
 

Additional Inherited Members

- Protected Member Functions inherited from ml::CSOObjectVector< T >
virtual void expand ()
 Grows vector, add extra block of size BLOCKSIZE.
 
virtual unsigned int appendUnsafe (T *elem)
 Appends element to back of vector, don't check on element being non-NULL Don't use this function directly!!
 

Detailed Description

template<class T>
class ml::CSOObjectHeap< T >

Heap structure with property i>2*i+1 and i>2*i+2 Parent i has children 2*i+1 and 2*i+2 Smallest values are stored closer to root of tree Elements are sorted while inserting them in the heap.

Definition at line 31 of file CSOObjectHeap.h.

Constructor & Destructor Documentation

◆ CSOObjectHeap()

template<class T >
ml::CSOObjectHeap< T >::CSOObjectHeap ( )

Standard constructor.

Definition at line 73 of file CSOObjectHeap.h.

◆ ~CSOObjectHeap()

template<class T >
ml::CSOObjectHeap< T >::~CSOObjectHeap ( )
override

Standard destructor.

Definition at line 80 of file CSOObjectHeap.h.

References ml::CSOObjectVector< T >::clear().

Member Function Documentation

◆ insert() [1/2]

template<class T >
void ml::CSOObjectHeap< T >::insert ( T * we)

◆ insert() [2/2]

template<class T >
void ml::CSOObjectHeap< T >::insert ( T * we,
float v )

Insert heap element and set value, resort heap.

Definition at line 121 of file CSOObjectHeap.h.

References ml::CSOObjectVector< T >::appendUnsafe(), ml::CSOObjectVector< T >::last(), mlrange_cast(), and ml::CSOObjectVector< T >::num().

◆ remove()

template<class T >
int ml::CSOObjectHeap< T >::remove ( T * we)
overridevirtual

Remove heap element, resort heap.

Reimplemented from ml::CSOObjectVector< T >.

Definition at line 141 of file CSOObjectHeap.h.

References ml::CSOObjectVector< T >::at(), ml::CSOObjectVector< T >::deleteLast(), mlrange_cast(), and ml::CSOObjectVector< T >::num().

◆ root()

template<class T >
T * ml::CSOObjectHeap< T >::root ( ) const

Get root (first) element of heap, typecast from CSOLiveWireNode to T.

Definition at line 88 of file CSOObjectHeap.h.

References ml::CSOObjectVector< T >::firstBoundsCheck(), and T.

◆ sort()

template<class T >
void ml::CSOObjectHeap< T >::sort ( )

◆ swap()

template<class T >
void ml::CSOObjectHeap< T >::swap ( unsigned int i,
unsigned int j )
overridevirtual

Swap two heap elements and resort heap.

Reimplemented from ml::CSOObjectVector< T >.

Definition at line 96 of file CSOObjectHeap.h.

References ml::CSOObjectVector< T >::at(), mlrange_cast(), and ml::CSOObjectVector< T >::swap().

◆ update()

template<class T >
void ml::CSOObjectHeap< T >::update ( T * we,
float nv )

Update given heap element with new value, resort heap.

Definition at line 176 of file CSOObjectHeap.h.

References mlrange_cast(), and ml::CSOObjectVector< T >::num().


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