#include <dheap.h>
Public Member Functions | |
bool | isHeap () |
check the double heap conditions are met, mainly for debugging purpouses | |
T & | max () |
T & | min () |
T | popMax () |
T | popMin () |
void | push (const T &elt) |
void | rebuild () |
Protected Member Functions | |
T & | at (int n) |
void | bubbleUp (int i) |
void | bubbleUpMax (int i) |
void | bubbleUpMin (int i) |
int | greatestChild (int i) |
int | isMax (int e) const |
int | leftChildMax (int i) const |
int | leftChildMin (int i) const |
int | parentMax (int i) const |
int | parentMin (int i) const |
int | smallestChild (int i) |
void | swap (int a, int b) |
void | trickleDownMax (int i) |
void | trickleDownMin (int i) |
Double ended heap inspired by Min-Max Heaps and Generalized Priority Queues M. D. ATKINSON,J.-R. SACK, N. SANTORO,and T. STROTHOTTE
This structure allows for quick extraction of biggest and smaller item out of a set with linear reconstruction of the ordering.
DHeap exposes the public interface of vector. (push_back(), resize() etc.).
Compared to a stl heap, rebuild is 15% longer, extraction is 2x longer, but you get both min and max extraction in log(n) time.
void DHeap< T >::bubbleUpMax | ( | int | i | ) | [inline, protected] |
void DHeap< T >::bubbleUpMin | ( | int | i | ) | [inline, protected] |
int DHeap< T >::greatestChild | ( | int | i | ) | [inline, protected] |
int DHeap< T >::leftChildMax | ( | int | i | ) | const [inline, protected] |
int DHeap< T >::leftChildMin | ( | int | i | ) | const [inline, protected] |
int DHeap< T >::smallestChild | ( | int | i | ) | [inline, protected] |
void DHeap< T >::trickleDownMax | ( | int | i | ) | [inline, protected] |
void DHeap< T >::trickleDownMin | ( | int | i | ) | [inline, protected] |