| 108 | /* Move element down into appropriate position in heap. */ |
| 109 | |
| 110 | static void |
| 111 | heapify_down (void **array, idx_t count, idx_t initial, |
| 112 | int (*compare) (void const *, void const *)) |
| 113 | { |
| 114 | void *element = array[initial]; |
| 115 | |
| 116 | idx_t parent = initial; |
| 117 | while (parent <= count >> 1) |
| 118 | { |
| 119 | idx_t child = 2 * parent; |
| 120 | |
| 121 | if (child < count && compare (array[child], array[child + 1]) < 0) |
| 122 | child++; |
| 123 | |
| 124 | if (compare (array[child], element) <= 0) |
| 125 | break; |
| 126 | |
| 127 | array[parent] = array[child]; |
| 128 | parent = child; |
| 129 | } |
| 130 | |
| 131 | array[parent] = element; |
| 132 | } |
| 133 | |
| 134 | /* Move element up into appropriate position in heap. */ |
| 135 |
no test coverage detected