Skip to content

Instantly share code, notes, and snippets.

@danlark1
Created April 12, 2022 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danlark1/3442e67c07b3e9a620b2fc6f2dff5685 to your computer and use it in GitHub Desktop.
Save danlark1/3442e67c07b3e9a620b2fc6f2dff5685 to your computer and use it in GitHub Desktop.
limited_ins_sort
const unsigned __limit = 8;
unsigned __count = 0;
for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {
if (__comp(*__i, *__j)) {
value_type __t(_VSTD::move(*__i));
_RandomAccessIterator __k = __j;
__j = __i;
do {
*__j = _VSTD::move(*__k);
__j = __k;
} while (__j != __first && __comp(__t, *--__k));
*__j = _VSTD::move(__t);
if (++__count == __limit)
return ++__i == __last;
}
__j = __i;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment