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

Additional Inherited Members

- Protected Member Functions inherited from ml::CSOObjectVector< T >
virtual void expand ()
 Grows vector, add extra block of size BLOCKSIZE. More...
 
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!! More...
 

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 heap element, resort heap.

Definition at line 106 of file CSOObjectHeap.h.

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

◆ 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(), 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(), and ml::CSOObjectVector< T >::num().

◆ root()

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

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(), 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 ml::CSOObjectVector< T >::num().


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