MeVisLab Toolbox Reference
|
Min-Heap structure with property v[i]<v[2*i+1] and v[i]<v[2*i+2] Parent at index i has children at indices 2*i+1 and 2*i+2 Smallest values are stored closer to root of tree. More...
#include <WEMHeap.h>
Public Member Functions | |
WEMHeap () | |
Standard constructor. | |
WEMHeap (WEMHeap &&) noexcept=default | |
WEMHeap & | operator= (WEMHeap &&) noexcept=default |
~WEMHeap () override | |
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) override |
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) override |
Removes the given heap element and resorts this heap. | |
void | sort () |
Sorts this heap. | |
void | clear () override |
Remove all elements from heap. | |
Public Member Functions inherited from ml::WEMVector< WEMPrimitive > | |
WEMVector (unsigned int init=0) | |
Standard constructor. | |
WEMVector (WEMVector &&other) noexcept | |
WEMVector & | operator= (WEMVector &&other) noexcept |
virtual | ~WEMVector () |
Standard destructor. | |
unsigned int | num () const |
Returns the number of elements in this vector. | |
WEMPrimitive * | at (unsigned int pos) const |
Returns the element at the given position or returns NULL if out of range. | |
WEMPrimitive * | first () |
Returns the first element. | |
const WEMPrimitive * | first () const |
Returns the first element. | |
WEMPrimitive * | last () |
Returns the last element. | |
const WEMPrimitive * | last () const |
Returns the last element. | |
virtual unsigned int | append (WEMPrimitive *elem) |
Appends the given element to back of this vector. | |
virtual void | deleteAt (unsigned int pos) |
Deletes the element at the given position. | |
virtual void | deleteLast () |
Deletes the last element of this vector. | |
virtual int | remove (WEMPrimitive *elem) |
Deletes the element given by its pointer. | |
virtual int | lookup (WEMPrimitive *elem) const |
Searches for the given element in this vector and returns its position. | |
virtual int | removeUnSwapped (WEMPrimitive *elem) |
Deletes the element given by its pointer. Keeps the order of the elements! | |
virtual void | destroy () |
Deletes all elements in this vector. | |
virtual void | replace (WEMPrimitive *elem, unsigned int pos) |
Replaces the given position with the given element. | |
void | reserve (unsigned int init) |
Reserves init elements, copies old ones if existing. | |
Additional Inherited Members | |
Protected Member Functions inherited from ml::WEMVector< WEMPrimitive > | |
virtual void | expand () |
Grow vector, add extra block of size BLOCKSIZE. | |
virtual unsigned int | appendUnsafe (WEMPrimitive *elem) |
Append element to back of vector, don't check on element being non-NULL. | |
Min-Heap structure with property v[i]<v[2*i+1] and v[i]<v[2*i+2] Parent at index i has children at indices 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.
ml::WEMHeap< T >::WEMHeap | ( | ) |
|
override |
|
overridevirtual |
Remove all elements from heap.
Reimplemented from ml::WEMVector< WEMPrimitive >.
Definition at line 278 of file WEMHeap.h.
References ml::WEMVector< T, fixedBufferSize >::clear(), and mlrange_cast().
void ml::WEMHeap< T >::insert | ( | WEMPrimitive * | wp | ) |
Inserts the given heap element and resorts this heap.
Definition at line 124 of file WEMHeap.h.
References ml::WEMVector< T, fixedBufferSize >::appendUnsafe(), and mlrange_cast().
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 138 of file WEMHeap.h.
References ml::WEMVector< T, fixedBufferSize >::appendUnsafe(), and mlrange_cast().
|
defaultnoexcept |
References mlrange_cast().
|
override |
Removes the given heap element and resorts this heap.
Definition at line 159 of file WEMHeap.h.
References ml::WEMMinHeapCompare::less(), and mlrange_cast().
T * ml::WEMHeap< T >::root | ( | ) |
Returns the root (first) element of this heap, typecast from WEMPrimitive to T.
Definition at line 90 of file WEMHeap.h.
References ml::WEMVector< T, fixedBufferSize >::first(), mlrange_cast(), and T.
Returns the root (first) element of this heap, typecast from WEMPrimitive to T.
void ml::WEMHeap< T >::sort | ( | ) |
Swaps two heap elements given by their indices and resorts this heap.
Reimplemented from ml::WEMVector< WEMPrimitive >.
Definition at line 114 of file WEMHeap.h.
References mlrange_cast(), and ml::WEMVector< T, fixedBufferSize >::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 194 of file WEMHeap.h.
References mlrange_cast().