I am new to using boost::fibonacci_heap
and had some questions regarding usage.
My pseudocode is along the lines of:
while (!heap.empty()) {
Get heap.top() //analyze
heap.pop()
//modify some other heap elements using heap handle
heap.update(handle_of_modified_entry)
}
My question is whether the heap.update()
call update the topped element which was freed by the pop
call. Am I causing invalid access to freed memory? Do I need to call update after pop to make sure the pop element is removed from the heap?
2
- pop: Effects: Removes the top element from the priority queue.
- update: Effects: Assigns v to the element handled by handle & updates the priority queue.
pop
is removing the top element from the priority queue so it is no longer inside the queue when you are to update it. So, unless you have evidence of the contrary, it should not cause the behavior you were worried about.
1