42template<
typename V,
typename P>
68template<
typename V,
typename P>
102 static constexpr std::size_t
BITS =
sizeof(
P) * 8;
125# if __has_builtin(__builtin_clz)
126 static std::size_t
msbSet(
unsigned int mask) {
130 static std::size_t
msbSet(
unsigned long mask) {
134 static std::size_t
msbSet(
unsigned long long mask) {
141template<
typename V,
typename P>
146template<
typename V,
typename P>
148 for (
Bucket& bucket : m_buckets) {
150 while (it !=
nullptr) {
151 auto next = it->next;
158template<
typename V,
typename P>
167template<
typename V,
typename P>
171 if (m_buckets[0] !=
nullptr) {
172 V result = std::move(m_buckets[0]->value);
178 if (m_buckets[0] !=
nullptr) {
179 m_buckets[0]->prev =
nullptr;
184 std::size_t
ind = BITS + 1 - msbSet(m_bucketMask);
187 m_buckets[
ind] =
nullptr;
189 m_bucketMask ^= (
P(1) << (8 *
sizeof(
P) -
ind));
194 for (
Bucket it = bucket; it !=
nullptr; it = it->
next) {
200 if (min->
prev !=
nullptr) {
206 if (min->
next !=
nullptr) {
210 V result = std::move(min->
value);
211 m_minimum = std::move(min->
priority);
214 while (bucket !=
nullptr) {
216 bucket->
prev =
nullptr;
225template<
typename V,
typename P>
227 std::size_t
ind = msbSet(
heapNode->priority ^ m_minimum);
230 if (m_buckets[
ind] !=
nullptr) {
236 m_bucketMask |= (
P(1) << (BITS -
ind));
Radix heap data structure implementation.
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
~RadixHeap()
Destructs the heap.
V pop()
Removes the top element from the heap and returns its value.
void insert(RadixHeapNode< V, P > *heapNode)
Buckets with values.
RadixHeap()
Creates empty heap.
bool empty() const
Checks whether the heap is empty.
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.
P m_minimum
Number of elements.
std::size_t size() const
Number of elements contained within the heap.
static std::size_t msbSet(T mask)
Returns most significant bit set on given mask.
RadixHeapNode< V, P > * next
RadixHeapNode(const V &nodeValue, const P &nodePriority)
RadixHeapNode< V, P > * prev
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.