| 53 | } |
| 54 | |
| 55 | static int __pushup |
| 56 | ( |
| 57 | heap_t *hp, |
| 58 | unsigned int idx |
| 59 | ) { |
| 60 | // 0 is the root node |
| 61 | while (0 != idx) |
| 62 | { |
| 63 | int parent = __parent(idx); |
| 64 | |
| 65 | // we are smaller than the parent |
| 66 | if(hp->cmp(hp->array[idx], hp->array[parent], hp->udata) < 0) { |
| 67 | return -1; |
| 68 | } else { |
| 69 | __swap(hp, idx, parent); |
| 70 | } |
| 71 | |
| 72 | idx = parent; |
| 73 | } |
| 74 | |
| 75 | return idx; |
| 76 | } |
| 77 | |
| 78 | static void __pushdown |
| 79 | ( |
no test coverage detected