#include <MinHeap.h>

Public Member Functions | |
| MinHeap (INDEX size) | |
| Construtor, giving initial array size. | |
| bool | empty () const |
| Returns true if the heap is empty. | |
| INDEX | size () const |
| Returns the number of elements in the heap. | |
| void | clear () |
| empties the heap | |
| const X & | top () const |
| Returns a reference to the top (i.e., smallest) element of the heap. It does not remove it. [O(1)]. | |
| void | push (X &x) |
| Adds an element to the heap [O(log n)]. | |
| X | pop () |
| Returns the top (i.e., smallest) element and removed it from the heap [O(log n)]. | |
| const X & | operator[] (INDEX idx) const |
| obtain const references to the element at index idx (the smallest array index is 0, as for traditional C-arrays) | |
Protected Member Functions | |
| INDEX | capacity () const |
| Returns the current array-size of the heap, i.e., the number of elements which can be added before the next resize occurs. | |
| void | heapup (INDEX idx) |
| void | heapdown () |
Private Attributes | |
| Array< X, INDEX > | data |
| INDEX | num |
It assumes that the data-elements are themselves comparable, i.e., the compare-function of the items implicitly defines the keys. Hence this datastructure allows no key-changing operations (decreaseKey, etc.).
The heap grows (using doubling) dynamically, if there are more elements added. Furthermore, MinHeap allows to be directly indexed using traditional array-syntax, e.g., for iterating over all its elements.
If your intended datastructure do not dorectly offer a compare function, but you have certain key-values (scores, etc.), you may want to use the convenience-class Valued < Score,X > to bind both together and use within MinHeap.
Definition at line 110 of file MinHeap.h.
| ogdf::MinHeap< X, INDEX >::MinHeap | ( | INDEX | size | ) | [inline] |
| bool ogdf::MinHeap< X, INDEX >::empty | ( | ) | const [inline] |
| INDEX ogdf::MinHeap< X, INDEX >::size | ( | ) | const [inline] |
| void ogdf::MinHeap< X, INDEX >::clear | ( | ) | [inline] |
| const X& ogdf::MinHeap< X, INDEX >::top | ( | ) | const [inline] |
| void ogdf::MinHeap< X, INDEX >::push | ( | X & | x | ) | [inline] |
| X ogdf::MinHeap< X, INDEX >::pop | ( | ) | [inline] |
| const X& ogdf::MinHeap< X, INDEX >::operator[] | ( | INDEX | idx | ) | const [inline] |
obtain const references to the element at index idx (the smallest array index is 0, as for traditional C-arrays)
Reimplemented in ogdf::Top10Heap< X, INDEX >.
| INDEX ogdf::MinHeap< X, INDEX >::capacity | ( | ) | const [inline, protected] |
Returns the current array-size of the heap, i.e., the number of elements which can be added before the next resize occurs.
Reimplemented in ogdf::Top10Heap< X, INDEX >.
| void ogdf::MinHeap< X, INDEX >::heapup | ( | INDEX | idx | ) | [inline, protected] |
| void ogdf::MinHeap< X, INDEX >::heapdown | ( | ) | [inline, protected] |
Array<X,INDEX> ogdf::MinHeap< X, INDEX >::data [private] |
INDEX ogdf::MinHeap< X, INDEX >::num [private] |