Add minor adjustments/clean-up
This commit is contained in:
@@ -21,12 +21,6 @@ static int right_sibling(int i) {
|
||||
return (i % 2 == 1) ? i + 1 : -1;
|
||||
}
|
||||
|
||||
void dlos_node_swap(dlos_ComparableNode *arr, int a, int b) {
|
||||
dlos_ComparableNode temp = arr[a];
|
||||
arr[a] = arr[b];
|
||||
arr[b] = temp;
|
||||
}
|
||||
|
||||
static int index_of_larger_child(int i, dlos_Heap *h) {
|
||||
int larger = left_child(i);
|
||||
if (larger >= h->size) {
|
||||
@@ -38,6 +32,12 @@ static int index_of_larger_child(int i, dlos_Heap *h) {
|
||||
return larger;
|
||||
}
|
||||
|
||||
void dlos_node_swap(dlos_ComparableNode *arr, int a, int b) {
|
||||
dlos_ComparableNode temp = arr[a];
|
||||
arr[a] = arr[b];
|
||||
arr[b] = temp;
|
||||
}
|
||||
|
||||
void dlos_sift_down(int i, dlos_Heap *h) {
|
||||
int target = index_of_larger_child(i, h);
|
||||
while (target > 0 && h->compare(&h->arr[i], &h->arr[target]) > 0) {
|
||||
|
Reference in New Issue
Block a user