MeVisLabToolboxReference
ml::WEMHeap< 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 Largest values are stored closer to root of tree. More...

#include <WEMHeap.h>

Inheritance diagram for ml::WEMHeap< T >:
ml::WEMVector< WEMPrimitive >

List of all members.

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.

Detailed Description

template<class T>
class ml::WEMHeap< 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 Largest values are stored closer to root of tree.

Elements are sorted while inserting them in the heap.

Definition at line 31 of file WEMHeap.h.


Constructor & Destructor Documentation

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

Standard constructor.

Definition at line 74 of file WEMHeap.h.

template<class T >
ml::WEMHeap< T >::~WEMHeap ( )

Standard destructor.

Definition at line 81 of file WEMHeap.h.


Member Function Documentation

template<class T >
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().

template<class T >
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().

template<class T >
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().

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

Returns the root (first) element of this heap, typecast from WEMPrimitive to T.

Definition at line 105 of file WEMHeap.h.

template<class 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.

template<class T >
void ml::WEMHeap< T >::sort ( )
template<class T >
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().

template<class T >
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().


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