Skip to content

Instantly share code, notes, and snippets.

@danlark1
Created April 20, 2022 08:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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