Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JinZhou5042 committed Nov 11, 2024
1 parent 1d4881f commit 01a2f50
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions dttools/src/priority_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ static int swim(struct priority_queue *pq, int k)
return 1;
}

while (k > 0 && pq->elements[(k - 1) / 2]->priority <= pq->elements[k]->priority) {
swap_elements(pq, k, (k - 1) / 2);
k = (k - 1) / 2;
}
while (k > 0 && pq->elements[(k - 1) / 2]->priority <= pq->elements[k]->priority) {
swap_elements(pq, k, (k - 1) / 2);
k = (k - 1) / 2;
}

return k;
}
Expand All @@ -63,17 +63,17 @@ static int sink(struct priority_queue *pq, int k)
return -1;
}

while (2 * k + 1 < pq->size) {
int j = 2 * k + 1;
if (j + 1 < pq->size && pq->elements[j]->priority <= pq->elements[j + 1]->priority) {
j++;
}
if (pq->elements[k]->priority >= pq->elements[j]->priority) {
break;
}
swap_elements(pq, k, j);
k = j;
}
while (2 * k + 1 < pq->size) {
int j = 2 * k + 1;
if (j + 1 < pq->size && pq->elements[j]->priority <= pq->elements[j + 1]->priority) {
j++;
}
if (pq->elements[k]->priority >= pq->elements[j]->priority) {
break;
}
swap_elements(pq, k, j);
k = j;
}

return k;
}
Expand Down

0 comments on commit 01a2f50

Please sign in to comment.