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

Heap structure with property i>2*i+1 and i>2*i+2. 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
 Returns the root (first) element of heap that is typecast from CSOLiveWireNode to T.
 
void swap (unsigned int i, unsigned int j) override
 Swaps two heap elements and resorts the heap.
 
void insert (T *we)
 Inserts heap element and resorts the heap.
 
void insert (T *we, float v)
 Inserts heap element, sets the value, and resorts the heap.
 
void update (T *we, float nv)
 Updates the specified heap element with the new value, and resorts the heap.
 
int remove (T *we) override
 Removes the heap element, and resorts the heap.
 
void sort ()
 Sorts the 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 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 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 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.
 

Additional Inherited Members

- Protected Member Functions inherited from ml::CSOObjectVector< T >
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::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 74 of file CSOObjectHeap.h.

◆ ~CSOObjectHeap()

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

Standard destructor.

Definition at line 81 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)

Inserts heap element and resorts the heap.

Definition at line 107 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 
)

Inserts heap element, sets the value, and resorts the heap.

Definition at line 122 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

Removes the heap element, and resorts the heap.

Returns the position where the element was remove or -1 if the element was not found.

Reimplemented from ml::CSOObjectVector< T >.

Definition at line 142 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 ( ) const

Returns the root (first) element of heap that is typecast from CSOLiveWireNode to T.

Definition at line 89 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

Swaps two heap elements and resorts the heap.

Reimplemented from ml::CSOObjectVector< T >.

Definition at line 97 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 
)

Updates the specified heap element with the new value, and resorts the heap.

Definition at line 177 of file CSOObjectHeap.h.

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


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