June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -35,11 +35,14 @@ char *pop (heap_t *h) {
|
|||
return NULL;
|
||||
}
|
||||
char *data = h->nodes[1].data;
|
||||
|
||||
h->nodes[1] = h->nodes[h->len];
|
||||
|
||||
h->len--;
|
||||
|
||||
i = 1;
|
||||
while (1) {
|
||||
k = i;
|
||||
while (i!=h->len+1) {
|
||||
k = h->len+1;
|
||||
j = 2 * i;
|
||||
if (j <= h->len && h->nodes[j].priority < h->nodes[k].priority) {
|
||||
k = j;
|
||||
|
|
@ -47,13 +50,9 @@ char *pop (heap_t *h) {
|
|||
if (j + 1 <= h->len && h->nodes[j + 1].priority < h->nodes[k].priority) {
|
||||
k = j + 1;
|
||||
}
|
||||
if (k == i) {
|
||||
break;
|
||||
}
|
||||
h->nodes[i] = h->nodes[k];
|
||||
i = k;
|
||||
}
|
||||
h->nodes[i] = h->nodes[h->len + 1];
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue