tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
stable_sort.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_ALGORITHM_STABLE_SORT_HPP
5#define TETL_ALGORITHM_STABLE_SORT_HPP
6
7#include <etl/_algorithm/insertion_sort.hpp>
8#include <etl/_functional/less.hpp>
9
10namespace etl {
11
12/// \ingroup algorithm
13/// @{
14
15/// Sorts the elements in the range `[first, last)` in non-descending
16/// order. The order of equivalent elements is guaranteed to be preserved.
17/// Elements are compared using the given comparison function comp.
18///
19/// https://en.cppreference.com/w/cpp/algorithm/stable_sort
20template <typename RandomIt, typename Compare>
21constexpr auto stable_sort(RandomIt first, RandomIt last, Compare comp) -> void
22{
23 etl::insertion_sort(first, last, comp);
24}
25
26template <typename RandomIt>
27constexpr auto stable_sort(RandomIt first, RandomIt last) -> void
28{
29 etl::stable_sort(first, last, etl::less());
30}
31
32/// @}
33
34} // namespace etl
35
36#endif // TETL_ALGORITHM_STABLE_SORT_HPP
constexpr auto stable_sort(RandomIt first, RandomIt last, Compare comp) -> void
Definition stable_sort.hpp:21
constexpr auto stable_sort(RandomIt first, RandomIt last) -> void
Definition stable_sort.hpp:27
Definition adjacent_find.hpp:9
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:15