Public Member Functions |
| | Top10Heap () |
| | Constructor generating a heap which holds the 10 elements with highest value ever added to the heap.
|
| | Top10Heap (INDEX size) |
| | Constructor generating a heap which holds the size elements with highest value ever added to the heap.
|
| INDEX | capacity () const |
| | Returns the size of the heap specified when constructing: this is the number of top elements stored.
|
| void | clear () |
| | empties the heap
|
| bool | empty () const |
| | Returns true if the heap contains no elements.
|
| bool | full () const |
| | Returns true if the heap is completely filled (i.e. the next push operation will return something)
|
| PushResult | insert (X &x, X &out) |
| | Alternative name for push().
|
| void | insertBlind (X &x, X &out) |
| | Alternative name for pushBlind().
|
| const X & | operator[] (INDEX idx) const |
| | obtain const references to the element at index idx
|
| PushResult | push (X &x, X &out) |
| | Tries to push the element x onto the heap (and may return a removed element as out).
|
| void | pushBlind (X &x) |
| | Simple (and slightly faster) variant of Top10Heap::push.
|
| INDEX | size () const |
| | Returns the number of elements in the heap.
|
Additional Inherited Members |
| | BinaryHeapSimple (INDEX size) |
| | Construtor, giving initial array size.
|
| X | extractMin () |
| | Returns the top (i.e., smallest) element and removed it from the heap [Same as pop(), O(log n)].
|
| const X & | getMin () const |
| | Returns a reference to the top (i.e., smallest) element of the heap. It does not remove it. [Same as top(), O(1)].
|
| void | insert (X &x) |
| | Adds an element to the heap [Same as push(), O(log n)].
|
| X | pop () |
| | Returns the top (i.e., smallest) element and removed it from the heap [Same as extractMin(), O(log n)].
|
| void | push (X &x) |
| | Adds an element to the heap [Same as insert(), O(log n)].
|
| const X & | top () const |
| | Returns a reference to the top (i.e., smallest) element of the heap. It does not remove it. [Same as getMin(), O(1)].
|
| void | heapdown () |
| void | heapup (INDEX idx) |
template<class X, class INDEX = int>
class ogdf::Top10Heap< X, INDEX >
A variant of BinaryHeapSimple which always holds only the X (e.g. X=10) elements with the highest keys.
It assumes that the data-elements are themselves comparable, i.e., the compare-function of the items implicitly defines the keys.
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 Prioritized < Priority,X > to bind both together and use within BinaryHeapSimple.
Definition at line 196 of file MinHeap.h.
template<class X, class INDEX = int>
obtain const references to the element at index idx
The smallest array index is 0, as for traditional C-arrays. Useful, e.g., when iterating through the final heap elements.
Reimplemented from ogdf::BinaryHeapSimple< X, INDEX >.
Definition at line 280 of file MinHeap.h.
template<class X, class INDEX = int>
Tries to push the element x onto the heap (and may return a removed element as out).
If the heap is not yet completely filled, the pushed element is accepted and added to the heap. The function returns Accepted, and the out parameter is not touched.
If the heap is filled and the key of the pushed element is too small to be accepted (i.e. the heap is filled with all larger elements), then the element if rejected: The funtion returns Rejected, and the out parameter is set to x.
If the heap is filled and the key of the pushed element is large enough to belong to the top elements, the element is accepted and the currently smallest element in the heap is removed from the heap. The function returns Swapped and sets the out parameter to the element removed from the heap.
You may want to use the convenience funtions successful and returnedSomething on the return-value if you are only interested certain aspects of the push.
Definition at line 240 of file MinHeap.h.