MeVisLabToolboxReference
|
Heap structure with property i>2*i+1 and i>2*i+2 Parent i has children 2*i+1 and 2*i+2 Largest values are stored closer to root of tree. More...
#include <WEMHeap.h>
Public Member Functions | |
WEMHeap () | |
Standard constructor. | |
~WEMHeap () | |
Standard destructor. | |
T * | root () |
Returns the root (first) element of this heap, typecast from WEMPrimitive to T. | |
const T * | root () const |
Returns the root (first) element of this heap, typecast from WEMPrimitive to T. | |
void | swap (unsigned int i, unsigned int j) |
Swaps two heap elements given by their indices and resorts this heap. | |
void | insert (WEMPrimitive *wp) |
Inserts the given heap element and resorts this heap. | |
void | insert (WEMPrimitive *wp, double v) |
Inserts the given heap element and sets its value, and resorts this heap. | |
void | update (WEMPrimitive *wp, double nv) |
Updates given heap element with the given value and resorts this heap. | |
int | remove (WEMPrimitive *wp) |
Removes the given heap element and resorts this heap. | |
void | sort () |
Sorts this heap. |
Heap structure with property i>2*i+1 and i>2*i+2 Parent i has children 2*i+1 and 2*i+2 Largest values are stored closer to root of tree.
Elements are sorted while inserting them in the heap.
ml::WEMHeap< T >::WEMHeap | ( | ) |
ml::WEMHeap< T >::~WEMHeap | ( | ) |
void ml::WEMHeap< T >::insert | ( | WEMPrimitive * | wp | ) |
Inserts the given heap element and resorts this heap.
Definition at line 123 of file WEMHeap.h.
References ml::WEMVector< T >::appendUnsafe(), and ml::WEMPrimitive::getHeapPosition().
void ml::WEMHeap< T >::insert | ( | WEMPrimitive * | wp, |
double | v | ||
) |
Inserts the given heap element and sets its value, and resorts this heap.
Definition at line 137 of file WEMHeap.h.
References ml::WEMVector< T >::appendUnsafe(), ml::WEMPrimitive::getHeapPosition(), and ml::WEMPrimitive::setHeapValue().
int ml::WEMHeap< T >::remove | ( | WEMPrimitive * | wp | ) | [virtual] |
Removes the given heap element and resorts this heap.
Reimplemented from ml::WEMVector< WEMPrimitive >.
Definition at line 158 of file WEMHeap.h.
References ml::WEMPrimitive::getHeapPosition(), and ml::WEMPrimitive::getHeapValue().
const T * ml::WEMHeap< T >::root | ( | ) | const |
Returns the root (first) element of this heap, typecast from WEMPrimitive to T.
T * ml::WEMHeap< T >::root | ( | ) |
Returns the root (first) element of this heap, typecast from WEMPrimitive to T.
Definition at line 89 of file WEMHeap.h.
References ml::WEMVector< T >::first(), and T.
void ml::WEMHeap< T >::sort | ( | ) |
Sorts this heap.
Definition at line 253 of file WEMHeap.h.
References ml::WEMVector< T >::append(), ml::WEMVector< T >::at(), ML_CHECK_NEW, ML_DELETE, and ml::WEMVector< T >::num().
void ml::WEMHeap< T >::swap | ( | unsigned int | i, |
unsigned int | j | ||
) | [virtual] |
Swaps two heap elements given by their indices and resorts this heap.
Reimplemented from ml::WEMVector< WEMPrimitive >.
Definition at line 113 of file WEMHeap.h.
References ml::WEMVector< T >::swap().
void ml::WEMHeap< T >::update | ( | WEMPrimitive * | wp, |
double | nv | ||
) |
Updates given heap element with the given value and resorts this heap.
Definition at line 193 of file WEMHeap.h.
References ml::WEMPrimitive::getHeapPosition(), ml::WEMPrimitive::getHeapValue(), and ml::WEMPrimitive::setHeapValue().