43 template<
typename V,
typename P>
53 : value(nodeValue), priority(nodePriority),
54 prev(nullptr), next(nullptr)
73 template<
typename V,
typename P>
111 static constexpr std::size_t BITS =
sizeof(P) * 8;
134 #if __has_builtin(__builtin_clz) 135 static std::size_t msbSet(
unsigned int mask) {
136 return mask == 0 ? 0 : (BITS - __builtin_clz(mask));
139 static std::size_t msbSet(
unsigned long mask) {
140 return mask == 0 ? 0 : (BITS - __builtin_clzl(mask));
143 static std::size_t msbSet(
unsigned long long mask) {
144 return mask == 0 ? 0 : (BITS - __builtin_clzll(mask));
152 template<
typename V,
typename P>
154 : m_size(0), m_minimum(0), m_bucketMask(0)
160 template<
typename V,
typename P>
165 while(it !=
nullptr) {
166 auto next = it->next;
174 template<
typename V,
typename P>
185 template<
typename V,
typename P>
213 for(
Bucket it = bucket; it !=
nullptr; it = it->
next) {
219 if(min->
prev !=
nullptr) {
225 if(min->
next !=
nullptr) {
233 while(bucket !=
nullptr) {
235 bucket->
prev =
nullptr;
245 template<
typename V,
typename P>
static std::size_t msbSet(T mask)
Returns most significant bit set on given mask.
V pop()
Removes the top element from the heap and returns its value.
std::size_t size() const
Number of elements contained within the heap.
bool empty() const
Checks whether the heap is empty.
RadixHeapNode< V, P > * push(const V &value, const P &priority)
Inserts a new node with given value and priority into a heap.
static constexpr std::size_t BITS
RadixHeapNode< V, P > * next
std::array< Bucket, BITS+1 > m_buckets
Mask describing state of buckets (for fast lookup).
P m_bucketMask
Priority of the lowest element so far.
const T & move(const T &v)
~RadixHeap()
Destructs the heap.
RadixHeapNode< V, P > * prev
void insert(RadixHeapNode< V, P > *heapNode)
Buckets with values.
The namespace for all OGDF objects.
RadixHeapNode(const V &nodeValue, const P &nodePriority)
P m_minimum
Number of elements.
Radix heap data structure implementation.
RadixHeap()
Creates empty heap.