Skip to content

Instantly share code, notes, and snippets.

@danlark1
Created Apr 20, 2022
Embed
What would you like to do?
// *__m is median. partition [__first, __m) < *__m and
// *__m <= [__m, __last)
//
// Special handling for almost sorted targets
while (true) {
while (__comp(*++__i, *__m));
while (!__comp(*--__j, *__m));
if (__i > __j) break;
swap(*__i, *__j);
}
swap(*__i, *__m);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment