55 class Access_Heap_Node>
57 :
public BinHeap<typename GT::Arc *, Distance_Compare<GT, Distance>>
70 Access_Heap_Node acc = Access_Heap_Node())
117 if (handle_src == heap_node)
122 assert(handle_tgt == heap_node);
137 if (heap_node ==
nullptr)
139 std::unique_ptr<Node> node(
new Node);
140 node->get_key() = arc;
142 heap_node = node.release();
155 typename GT::Arc *old_arc = arc_in_heap;
163 arc_in_heap = old_arc;
176 std::unique_ptr<Node> heap_node(this->
getMin_ne());
177 assert(heap_node.get() ==
top);
215 class Access_Heap_Node>
237 auto *arc = heap_node->data;
240 if (handle_src == heap_node)
245 assert(handle_tgt == heap_node);
258 if (p->child !=
nullptr)
268 handle_type head = p->parent ==
nullptr ? first : p->parent->child;
269 if (p->right != head)
288 Access_Heap_Node acc = Access_Heap_Node())
300 :
access_node(std::move(other.access_node)),
heap(std::move(other.heap))
311 heap = std::move(other.heap);
323 if (heap_node ==
nullptr)
330 typename GT::Arc *arc_in_heap = heap_node->data;
347 auto *arc = heap_node->data;
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
Node * get_min_node() const noexcept
Returns a pointer to the minimum node.
void clear() noexcept(std::is_nothrow_destructible_v< T >)
Removes all elements from the heap.
Node * insert(const T &val)
Inserts a new element (copy).
Node * handle_type
Type alias for node handles.
T extract_min()
Extracts and returns the minimum element.
Compare & get_compare() noexcept
Returns the comparison functor that orders the heap.
void decrease_key(Node *x, const T &k)
Decreases the key of a node.
bool is_empty() const noexcept
Checks if the heap is empty.
Node * insert(Node *p) noexcept(nothrow_cmp)
Inserts a node into a heap.
Compare & get_compare() noexcept
void update(Node *p) noexcept(nothrow_cmp)
Updates the priority of a node contained in the heap.
void remove_all_and_delete() noexcept
Deletes all the nodes of the heap, invokes the destructors of the removed nodes, and frees all the me...
Node * getMin_ne() noexcept(nothrow_cmp)
Removes the node with the lowest priority from a heap that is not empty.
void for_each_in_preorder(Operation &operation) const
Node * top()
Returns the node with the lowest priority according to the comparison criterion specified in the decl...
ArcFibonacciHeap & operator=(const ArcFibonacciHeap &)=delete
void empty()
Remove all heap nodes and delete their memory, after clearing the handles that the access functor kee...
Distance & get_distance()
Return the distance functor of the comparison that orders the arcs of this heap and chooses between t...
handle_type & handle_of(handle_type heap_node)
void clear()
Empties the container.
typename Heap::handle_type handle_type
handle_type & handle_ref(typename GT::Node *p)
~ArcFibonacciHeap()
Destructor. Clears all remaining heap nodes, as empty() does.
bool is_empty() const noexcept
Return true if the heap is empty.
ArcFibonacciHeap(const ArcFibonacciHeap &)=delete
Copying is disabled (heap manages internal node memory)
ArcFibonacciHeap(ArcFibonacciHeap &&other) noexcept
Move construction transfers ownership of heap nodes and the distance.
ArcFibonacciHeap(Distance __dist=Distance(), Access_Heap_Node acc=Access_Heap_Node())
Construct an empty Fibonacci arc heap with the given distance functor and heap-node access policy.
ArcFibonacciHeap & operator=(ArcFibonacciHeap &&other) noexcept
Move assignment transfers ownership of heap nodes and the distance, after emptying this heap as empty...
void put_arc(typename GT::Arc *arc, typename GT::Node *tgt)
Insert or update an arc associated with a target node, keeping the smallest-distance arc per node in ...
void clear_handles(handle_type first)
Access_Heap_Node access_node
GT::Arc * get_min_arc()
Extract the arc with minimum distance from the heap and clear its node-to-heap mapping.
ArcHeap & operator=(ArcHeap &&other) noexcept
Move assignment transfers ownership of heap nodes and the distance, after emptying this heap as empty...
ArcHeap(Distance __dist=Distance(), Access_Heap_Node acc=Access_Heap_Node())
Construct an empty arc heap with the given distance functor and heap-node access policy.
ArcHeap(const ArcHeap &)=delete
Copying is disabled (heap manages internal node memory)
Distance & get_distance()
Return the distance functor of the comparison that orders the arcs of this heap and chooses between t...
ArcHeap(ArcHeap &&other) noexcept
Move construction transfers ownership of heap nodes and the distance.
handle_type & handle_of(Node *heap_node)
Access_Heap_Node access_node
void clear()
Empties the container.
~ArcHeap()
Destructor. Clears all remaining heap nodes, as empty() does.
void put_arc(typename GT::Arc *arc, typename GT::Node *tgt)
Insert or update an arc associated with a target node, keeping the smallest-distance arc per node in ...
ArcHeap & operator=(const ArcHeap &)=delete
BinHeap< typename GT::Arc *, Distance_Compare< GT, Distance > > Heap
void empty()
Remove all heap nodes and delete their memory, after clearing the handles that the access functor kee...
GT::Arc * get_min_arc()
Extract the arc with minimum distance from the heap and clear its node-to-heap mapping.
void * tgt_node
Please don't use.
T & swap(T &t1, T &t2)
Generic swap using object's swap method.
Node heap without virtual destructor.
Comparison functor for arc weights/distances.
Binary heap implementation using tree structure.
Fibonacci Heap implementation.
Utility algorithms and operations for graphs.