Further improve __insertion_sort

Thanks GibHaltmannKill


Former-commit-id: 906d8406ab
This commit is contained in:
Henrique Gemignani Passos Lima
2022-11-28 17:00:16 +02:00
parent 0d56857ce2
commit 15999e4cbb
2 changed files with 11 additions and 11 deletions
+5 -5
View File
@@ -39,12 +39,12 @@ void __insertion_sort(It first, It last, Cmp cmp) {
for (It next = first + 1; next < last; ++next) {
typename iterator_traits< It >::value_type value = *next;
It t1 = next;
for (It t2 = next - 1; first < t1 && cmp(value, *t2); --t2) {
*t1 = *t2;
--t1;
It t1 = next - 1;
It t2 = next;
while (first < t2 && cmp(value, *t1)) {
*t2-- = *t1--;
}
*t1 = value;
*t2 = value;
}
}