tudocomp
– The TU Dortmund Compression Framework
|
Represents a binary max heap backed by an external array of keys. More...
#include <ArrayMaxHeap.hpp>
Public Member Functions | |
ArrayMaxHeap (array_t &array, const size_t array_size, const size_t heap_size) | |
Default constructor. More... | |
void | insert (len_t i) |
Inserts an item into the heap. More... | |
void | remove (len_t i) |
Removes an item from the heap. More... | |
template<typename key_t > | |
void | decrease_key (len_t i, key_t value) |
Decreases the key of item in the heap. More... | |
bool | contains (len_t i) const |
Checks whether or not an item is contained in this heap. More... | |
size_t | size () const |
Yields the number of items currently stored in the heap. More... | |
size_t | get_max () const |
Gets the first (maximum) item from the heap. More... | |
size_t | top () const |
Gets the top (first, maximum) item from the heap. More... | |
len_t | key (len_t i) const |
Gets an item's key. More... | |
Represents a binary max heap backed by an external array of keys.
The max heap induces an order on the indices of the key array it is backed by. The first element of the heap is the index of the largest item in the key array.
array_t | The key array type. Must support the [] operator. |
Definition at line 17 of file ArrayMaxHeap.hpp.
|
inline |
Default constructor.
Note that the constructor will not insert any items into the heap and serves merely for initialization.
array | The array of keys sorted by this heap. |
array_size | The size of the key array. |
heap_size | The maximum amount of items stored in the heap. |
Definition at line 65 of file ArrayMaxHeap.hpp.
|
inline |
Checks whether or not an item is contained in this heap.
i | The index of the item in the key array. |
Definition at line 198 of file ArrayMaxHeap.hpp.
|
inline |
Decreases the key of item in the heap.
key_t | the key type. |
i | The index of the item in the key array. The key is retrieved from there. |
value | The new key value. |
Definition at line 177 of file ArrayMaxHeap.hpp.
|
inline |
Gets the first (maximum) item from the heap.
Definition at line 210 of file ArrayMaxHeap.hpp.
|
inline |
Inserts an item into the heap.
i | The index of the item in the key array. The key is retrieved from there. |
Definition at line 77 of file ArrayMaxHeap.hpp.
|
inline |
Gets an item's key.
i | The index of the item in the key array. |
Definition at line 224 of file ArrayMaxHeap.hpp.
|
inline |
Removes an item from the heap.
i | The index of the item in the key array. The key is retrieved from there. |
Definition at line 152 of file ArrayMaxHeap.hpp.
|
inline |
Yields the number of items currently stored in the heap.
Definition at line 204 of file ArrayMaxHeap.hpp.
|
inline |
Gets the top (first, maximum) item from the heap.
Definition at line 216 of file ArrayMaxHeap.hpp.