-
-
Save danlark1/f50cddf0e4a2f12caad61875c4edbe12 to your computer and use it in GitHub Desktop.
sort5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <class _Compare, class _ForwardIterator> | |
unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, | |
_ForwardIterator __x4, _ForwardIterator __x5, _Compare __c) { | |
unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c); | |
if (__c(*__x5, *__x4)) { | |
swap(*__x4, *__x5); | |
++__r; | |
if (__c(*__x4, *__x3)) { | |
swap(*__x3, *__x4); | |
++__r; | |
if (__c(*__x3, *__x2)) { | |
swap(*__x2, *__x3); | |
++__r; | |
if (__c(*__x2, *__x1)) { | |
swap(*__x1, *__x2); | |
++__r; | |
} | |
} | |
} | |
} | |
return __r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment