File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
source/containers/test/sort Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import containers.algorithms.sort.chunked_insertion_sort;
10
10
import bounded;
11
11
import containers;
12
12
import std_module;
13
+ import tv;
13
14
14
15
namespace {
15
16
@@ -58,13 +59,17 @@ constexpr auto insertion_sort = [](containers::range auto && r) -> void {
58
59
auto const first = containers::begin (r);
59
60
auto const last = containers::end (r);
60
61
for (auto it = first; it != last; ++it) {
61
- auto const insertion = containers::find_last (containers::subrange (first, it), *it);
62
- // TODO: Relocate-based algorithm
63
- std::rotate (
64
- containers::maybe_legacy_iterator (insertion),
65
- containers::maybe_legacy_iterator (it),
66
- containers::maybe_legacy_iterator (containers::next (it))
62
+ auto const sorted = containers::subrange (first, it);
63
+ auto const insertion = ::containers::find_if (
64
+ sorted,
65
+ [&](auto const & value) { return *it < value; }
67
66
);
67
+ auto temp = tv::relocate_into_storage (*it);
68
+ containers::uninitialized_relocate_backward (
69
+ containers::subrange (insertion, it),
70
+ containers::next (it)
71
+ );
72
+ bounded::relocate_at (*insertion, temp.value );
68
73
}
69
74
};
70
75
You can’t perform that action at this time.
0 commit comments