cvflann::Heap< T > Class Template Reference

#include <heap.h>

List of all members.

Public Member Functions

 Heap (int size)
 ~Heap ()
int size ()
bool empty ()
void clear ()
void insert (T value)
bool popMin (T &value)
void heapify (int parent)

Detailed Description

template<typename T>
class cvflann::Heap< T >

Priority Queue Implementation

The priority queue is implemented with a heap. A heap is a complete (full) binary tree in which each parent is less than both of its children, but the order of the children is unspecified. Note that a heap uses 1-based indexing to allow for power-of-2 location of parents and children. We ignore element 0 of Heap array.


Constructor & Destructor Documentation

template<typename T>
cvflann::Heap< T >::Heap ( int  size  ) 

Constructor.

Params: size = heap size

template<typename T>
cvflann::Heap< T >::~Heap (  ) 

Destructor.


Member Function Documentation

template<typename T>
int cvflann::Heap< T >::size (  ) 

Returns: heap size

template<typename T>
bool cvflann::Heap< T >::empty (  ) 

Tests if the heap is empty

Returns: true is heap empty, false otherwise

template<typename T>
void cvflann::Heap< T >::clear (  ) 

Clears the heap.

template<typename T>
void cvflann::Heap< T >::insert ( T  value  ) 

Insert a new element in the heap.

We select the next empty leaf node, and then keep moving any larger parents down until the right location is found to store this element.

Params: value = the new element to be inserted in the heap

template<typename T>
bool cvflann::Heap< T >::popMin ( T value  ) 

Returns the node of minimum value from the heap (top of the heap).

Params: value = out parameter used to return the min element Returns: false if heap empty

template<typename T>
void cvflann::Heap< T >::heapify ( int  parent  ) 

Reorganizes the heap (a parent is smaller than its children) starting with a node.

Params: parent = node form which to start heap reorganization.


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