possibly do the correct comparison I hope
This commit is contained in:
parent
95fc5a1e1d
commit
b8ec6963be
1 changed files with 24 additions and 7 deletions
|
@ -41,18 +41,35 @@ fn dual_pivot_partition(list: &mut [u64], res: &mut SortResult) -> (usize, usize
|
|||
let q = list[list.len() - 1];
|
||||
|
||||
while k <= g {
|
||||
if compare(list[k], p, &mut comps) == LESS {
|
||||
swap(list, k, l, &mut swaps);
|
||||
l += 1;
|
||||
} else if compare(list[k], q, &mut comps) != LESS {
|
||||
while compare(list[g], q, &mut comps) == GREATER && k < g {
|
||||
if ((list.len() - 1) - g) > (l - 1) {
|
||||
if compare(list[k], q, &mut comps) != LESS {
|
||||
while compare(list[g], q, &mut comps) == GREATER && k < g {
|
||||
g -= 1;
|
||||
}
|
||||
swap(list, k, g, &mut swaps);
|
||||
g -= 1;
|
||||
if compare(list[k], p, &mut comps) == LESS {
|
||||
swap(list, k, l, &mut swaps);
|
||||
l += 1;
|
||||
}
|
||||
} else if compare(list[k], p, &mut comps) == LESS {
|
||||
swap(list, k, l, &mut swaps);
|
||||
l += 1;
|
||||
}
|
||||
swap(list, k, g, &mut swaps);
|
||||
g -= 1;
|
||||
} else {
|
||||
if compare(list[k], p, &mut comps) == LESS {
|
||||
swap(list, k, l, &mut swaps);
|
||||
l += 1;
|
||||
} else if compare(list[k], q, &mut comps) != LESS {
|
||||
while compare(list[g], q, &mut comps) == GREATER && k < g {
|
||||
g -= 1;
|
||||
}
|
||||
swap(list, k, g, &mut swaps);
|
||||
g -= 1;
|
||||
if compare(list[k], p, &mut comps) == LESS {
|
||||
swap(list, k, l, &mut swaps);
|
||||
l += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
k += 1;
|
||||
|
|
Loading…
Reference in a new issue