Not sure what you're trying to do with this code:
MinPriority::priority& MinPriority::HEAP_EXTRACT_MIN(*this) //dequeue's min element of tree
{
MinPriority::priority& min = heapArray.front();
heapArray.erase(heapArray.begin());
MIN_HEAPIFY(0);
return min;
}
But you have a few issues here:
- The method has no argument type, it just has *this which makes no sense.
- You are returning a reference to a temporary, this is undefined behaviour and will likely crash.
I think what you actually wanted was a wrapper method to return the front of the deque and remove it:
MinPriority::priority MinPriority::PopFront()
{
// Copy of the front element
MinPriority::priority min = heapArray.front();
// Remove/destroy the front element
heapArray.erase(heapArray.begin());
// Return the copy
return min;
}