Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions algorithms_task_6/student/include/impl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#pragma once
#include <algorithm>
#include <list>

template <typename Container>
void stable_sort(Container& target) {
std::stable_sort(target.begin(), target.end());
}

template<typename T>
void stable_sort(std::list<T>& target) {
target.sort();
}

/**
* @todo insert_to_sorted
Expand All @@ -18,4 +28,7 @@ void insert_to_sorted(Sequence& target, const FwIt sourceBegin, const FwIt sourc
static_assert(std::is_const<typename std::remove_reference<
typename std::iterator_traits<FwIt>::reference>::type>::value,
"FwIt must point to const data");

std::copy(sourceBegin, sourceEnd, std::back_inserter(target));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider search + insertion

stable_sort(target);
}