[priority-queue] More assert adjustment

This commit is contained in:
Behdad Esfahbod 2022-11-16 12:06:44 -07:00
parent 620ddd762d
commit 02949cf64f
1 changed files with 4 additions and 2 deletions

View File

@ -63,6 +63,8 @@ struct hb_priority_queue_t
heap.arrayZ[0] = heap.arrayZ[heap.length - 1]; heap.arrayZ[0] = heap.arrayZ[heap.length - 1];
heap.shrink (heap.length - 1); heap.shrink (heap.length - 1);
if (!is_empty ())
bubble_down (0); bubble_down (0);
return result; return result;
@ -100,7 +102,7 @@ struct hb_priority_queue_t
void bubble_down (unsigned index) void bubble_down (unsigned index)
{ {
assert (index <= heap.length); assert (index < heap.length);
unsigned left = left_child (index); unsigned left = left_child (index);
unsigned right = right_child (index); unsigned right = right_child (index);