add comments to dual pivot quicksort
This commit is contained in:
parent
9bc0a4e198
commit
c8d54ab6c1
1 changed files with 6 additions and 0 deletions
|
@ -41,7 +41,9 @@ fn dual_pivot_partition(list: &mut [u64], res: &mut SortResult) -> (usize, usize
|
|||
let q = list[list.len() - 1];
|
||||
|
||||
while k <= g {
|
||||
// l > s
|
||||
if ((list.len() - 1) - g) > (l - 1) {
|
||||
// list[k] >= q
|
||||
if compare(list[k], q, &mut comps) != LESS {
|
||||
while compare(list[g], q, &mut comps) == GREATER && k < g {
|
||||
g -= 1;
|
||||
|
@ -52,14 +54,18 @@ fn dual_pivot_partition(list: &mut [u64], res: &mut SortResult) -> (usize, usize
|
|||
swap(list, k, l, &mut swaps);
|
||||
l += 1;
|
||||
}
|
||||
// list[k] < p
|
||||
} else if compare(list[k], p, &mut comps) == LESS {
|
||||
swap(list, k, l, &mut swaps);
|
||||
l += 1;
|
||||
}
|
||||
// l < s
|
||||
} else {
|
||||
// list[k] < p
|
||||
if compare(list[k], p, &mut comps) == LESS {
|
||||
swap(list, k, l, &mut swaps);
|
||||
l += 1;
|
||||
// list[k] >= q
|
||||
} else if compare(list[k], q, &mut comps) != LESS {
|
||||
while compare(list[g], q, &mut comps) == GREATER && k < g {
|
||||
g -= 1;
|
||||
|
|
Loading…
Reference in a new issue