Update: removal of unused assert
@@ -99,10 +99,10 @@ static int smallestGrandChild(PriorityQueue *queue, int i, bool invert)
{
return i;
}
- Item lv = at(l);
int min = l;
for(int r=l+1; r<queue->itemsAmount && r < l+4; r++)
{ //iterate on three grandsiblings (they are consecutive)
+ Item lv = at(l);
Item rv = at(r);
if((rv.priority < lv.priority)^invert)
{
@@ -114,7 +114,7 @@ static int smallestGrandChild(PriorityQueue *queue, int i, bool invert)
}
void trickleDown(PriorityQueue *queue, int i, bool invert)
-{ //assert(invert == isOnMaxLevel(i));
+{
while(1)
{
//enforce min-max property on level(i), we need to check children and grandchildren
