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;
1010import bounded;
1111import containers;
1212import std_module;
13+ import tv;
1314
1415namespace {
1516
@@ -58,13 +59,17 @@ constexpr auto insertion_sort = [](containers::range auto && r) -> void {
5859 auto const first = containers::begin (r);
5960 auto const last = containers::end (r);
6061 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; }
6766 );
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 );
6873 }
6974};
7075
You can’t perform that action at this time.
0 commit comments