Added catch of erase of the last element of heap.
This commit is contained in:
parent
20ce2ada9f
commit
76f7f77883
@ -204,13 +204,22 @@ inline void heap_array<T, CmpT>::erase(size_t i) {
|
||||
m_Locked = true;
|
||||
|
||||
// Debug check to ensure element is still present
|
||||
// assert(! removed(i));
|
||||
if (removed(i)) throw "heap_array<T, CmpT>::erase(size_t i) error";
|
||||
|
||||
size_t j = m_Finder[i];
|
||||
Swap(j, size() - 1);
|
||||
m_Heap.pop_back();
|
||||
Adjust(j);
|
||||
|
||||
if (j==m_Heap.size()-1)
|
||||
{
|
||||
m_Heap.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
Swap(j, size() - 1);
|
||||
m_Heap.pop_back();
|
||||
Adjust(j);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user