template class cvflann::Heap
Overview
Priority Queue Implementation
The priority queue is implemented with a heap. Moreā¦
#include <heap.h> template <typename T> class Heap { public: // structs struct CompareT; // construction Heap(int sz); // methods void clear(); bool empty(); void insert(T value); bool popMin(T& value); int size(); };
Detailed Documentation
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.
Construction
Heap(int sz)
Constructor.
Params: sz = heap size
Methods
void clear()
Clears the heap.
bool empty()
Tests if the heap is empty
Returns: true is heap empty, false otherwise
void 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
bool 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
int size()
Returns: heap size