Skip to content

Commit

Permalink
demo
Browse files Browse the repository at this point in the history
  • Loading branch information
bangoc committed Jan 14, 2024
1 parent 01550da commit 05050c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1,020 deletions.
10 changes: 5 additions & 5 deletions algo/algo.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ static void heap_shift_down(void *a, int n, int sz, int i, compare_fnt cmp) {
}

static void heap_shift_up(void *a, int n, int sz, int i, compare_fnt cmp) {
int j = HTOP(i);
while (i > 0 && cmp(a + j * sz, a + i * sz) < 0) {
vswap(a + i * sz, a + j * sz, sz);
i = j;
j = HTOP(i);
int top = HTOP(i);
while (i > 0 && cmp(a + top * sz, a + i * sz) < 0) {
vswap(a + i * sz, a + top * sz, sz);
i = top;
top = HTOP(top);
}
}

Expand Down
10 changes: 5 additions & 5 deletions all/cgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ static void heap_shift_down(void *a, int n, int sz, int i, compare_fnt cmp) {
}
}
static void heap_shift_up(void *a, int n, int sz, int i, compare_fnt cmp) {
int j = HTOP(i);
while (i > 0 && cmp(a + j * sz, a + i * sz) < 0) {
vswap(a + i * sz, a + j * sz, sz);
i = j;
j = HTOP(i);
int top = HTOP(i);
while (i > 0 && cmp(a + top * sz, a + i * sz) < 0) {
vswap(a + i * sz, a + top * sz, sz);
i = top;
top = HTOP(top);
}
}
static void heap_make(void *a, int n, int sz, compare_fnt cmp) {
Expand Down
Loading

0 comments on commit 05050c4

Please sign in to comment.