This template class implements a heap with a fixed maximal size, however a reallocation can be performed if required.
#include <bheap.h>
Inheritance diagram for ABA_BHEAP< Type, Key >::
|
The output operator writes the elements of the heap together with their keys on an output stream.
This template class implements a heap with a fixed maximal size, however a reallocation can be performed if required.
Definition at line 74 of file bheap.h.
A constructor.
A constructor with initialization.
The heap is initialized from an ABA_BUFFER of elements and a corresponding ABA_BUFFER of keys. The running time is O(n) for n elements.
Inserts an item with a key into the heap.
It is a fatal error to perform this operation if the heap is full. If the precompiler flag -DABACUSSAFE is set, we check if the heap is not already full.
The minimum element of the heap. This operation must not be performed if the heap is empty. Since the heap property holds the element having minimal key is always stored in heap_[0].
The key of the minimum element of the heap. This operation must not be performed if the heap is empty. Since the heap property holds the element having minimal key is always stored in heap_[0] and its key in key_[0].
Accesses and removes the minimum element from the heap.
The minimum element is stored in the root of the tree, i.e., in heap_[0]. If the heap does not become empty by removing the minimal element, we move the last element stored in heap_ to the root (heap_[0]). Whereas this operation can destroy the heap property, the two subtrees rooted at nodes 1 and 2 still satisfy the heap property. Hence calling heapify(0) will restore the overall heap property.
The minimum element of the heap.
The maximal number of elements which can be stored in the heap.
The number of elements in the heap.
true If there are no elements in the heap,
false otherwise.
Changes the size of the heap.
Stops with an error message if the heap properties are violated.
This function is used for debugging this class.
Returns the index of the left son of node i.
Returns the index of the right son of node i.
Returns the index of the father of element i.
Is the central function to maintain the heap property.
The function assumes that the two trees rooted at left(i) and right(i) fulfil already the heap property and restores the heap property of the (sub-) tree rooted at i.
The output operator writes the elements of the heap together with their keys on an output stream.
A reference to the output stream.
Definition at line 216 of file bheap.h.
Definition at line 217 of file bheap.h.
Definition at line 218 of file bheap.h.
Definition at line 219 of file bheap.h.
The documentation for this class was generated from the following file: