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];
|
let q = list[list.len() - 1];
|
||||||
|
|
||||||
while k <= g {
|
while k <= g {
|
||||||
if compare(list[k], p, &mut comps) == LESS {
|
if ((list.len() - 1) - g) > (l - 1) {
|
||||||
swap(list, k, l, &mut swaps);
|
if compare(list[k], q, &mut comps) != LESS {
|
||||||
l += 1;
|
while compare(list[g], q, &mut comps) == GREATER && k < g {
|
||||||
} else if compare(list[k], q, &mut comps) != LESS {
|
g -= 1;
|
||||||
while compare(list[g], q, &mut comps) == GREATER && k < g {
|
}
|
||||||
|
swap(list, k, g, &mut swaps);
|
||||||
g -= 1;
|
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);
|
} else {
|
||||||
g -= 1;
|
|
||||||
if compare(list[k], p, &mut comps) == LESS {
|
if compare(list[k], p, &mut comps) == LESS {
|
||||||
swap(list, k, l, &mut swaps);
|
swap(list, k, l, &mut swaps);
|
||||||
l += 1;
|
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;
|
k += 1;
|
||||||
|
|
Loading…
Reference in a new issue