Radix heap data structure implementation. More...
#include <ogdf/basic/heap/RadixHeap.h>
Public Member Functions | |
RadixHeap () | |
Creates empty heap. More... | |
~RadixHeap () | |
Destructs the heap. More... | |
bool | empty () const |
Checks whether the heap is empty. More... | |
V | pop () |
Removes the top element from the heap and returns its value. More... | |
RadixHeapNode< V, P > * | push (const V &value, const P &priority) |
Inserts a new node with given value and priority into a heap. More... | |
std::size_t | size () const |
Number of elements contained within the heap. More... | |
Private Types | |
using | Bucket = RadixHeapNode< V, P > * |
Private Member Functions | |
void | insert (RadixHeapNode< V, P > *heapNode) |
Buckets with values. More... | |
Static Private Member Functions | |
template<typename T > | |
static std::size_t | msbSet (T mask) |
Returns most significant bit set on given mask. More... | |
Private Attributes | |
P | m_bucketMask |
Priority of the lowest element so far. More... | |
std::array< Bucket, BITS+1 > | m_buckets |
Mask describing state of buckets (for fast lookup). More... | |
P | m_minimum |
Number of elements. More... | |
std::size_t | m_size |
Static Private Attributes | |
static constexpr std::size_t | BITS = sizeof(P) * 8 |
Radix heap data structure implementation.
It is just a simple implementation of the idea sketched here: http://ssp.impulsetrain.com/radix-heap.html
To achieve best performance it also uses low-level word functions where avaliable.
V | Denotes type of values of inserted elements. |
P | Denotes type of integral priorities of inserted elements. |
Definition at line 67 of file RadixHeap.h.
|
private |
Definition at line 99 of file RadixHeap.h.
ogdf::RadixHeap< V, P >::RadixHeap |
Creates empty heap.
Definition at line 140 of file RadixHeap.h.
ogdf::RadixHeap< V, P >::~RadixHeap |
Destructs the heap.
Definition at line 145 of file RadixHeap.h.
|
inline |
Checks whether the heap is empty.
Definition at line 96 of file RadixHeap.h.
|
inlineprivate |
Buckets with values.
Inserts heapNode
to the appropriate bucket.
Definition at line 224 of file RadixHeap.h.
|
inlinestaticprivate |
Returns most significant bit set on given mask.
Definition at line 113 of file RadixHeap.h.
V ogdf::RadixHeap< V, P >::pop |
Removes the top element from the heap and returns its value.
Behaviour of this function is undefined if the heap is empty.
Definition at line 166 of file RadixHeap.h.
RadixHeapNode< V, P > * ogdf::RadixHeap< V, P >::push | ( | const V & | value, |
const P & | priority | ||
) |
Inserts a new node with given value
and priority
into a heap.
value | A value of inserted element. |
priority | A priority of inserted element. |
Definition at line 157 of file RadixHeap.h.
|
inline |
Number of elements contained within the heap.
Definition at line 93 of file RadixHeap.h.
|
staticconstexprprivate |
Definition at line 100 of file RadixHeap.h.
|
private |
Priority of the lowest element so far.
Definition at line 105 of file RadixHeap.h.
|
private |
Mask describing state of buckets (for fast lookup).
Definition at line 106 of file RadixHeap.h.
|
private |
Number of elements.
Definition at line 104 of file RadixHeap.h.
|
private |
Definition at line 102 of file RadixHeap.h.