I need to update the midpoint
variable to "chase" the midpoint value if the midpoint gets swapped:
uint partition(Tester &tester, uint start, uint end) {
uint midpoint = (start + end) >> 1;
for (;;) {
while (tester.compare(start, midpoint) < 0)
++start;
while (tester.compare(midpoint, end) < 0)
--end;
if (start >= end)
return end;
if (midpoint == start)
midpoint = end;
else if (midpoint == end)
midpoint = start;
tester.swap(start++, end--);
}
}