tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
partial_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_PARTIAL_SORT_HPP
5#define TETL_ALGORITHM_PARTIAL_SORT_HPP
6
7#include <etl/_algorithm/sort.hpp>
8#include <etl/_utility/ignore_unused.hpp>
9
10namespace etl {
11
12/// \brief Rearranges elements such that the range `[first, middle)` contains
13/// the sorted `middle - first` smallest elements in the range `[first, last)`.
14/// The order of equal elements is not guaranteed to be preserved. The order of
15/// the remaining elements in the range `[middle, last)` is unspecified.
16///
17/// https://en.cppreference.com/w/cpp/algorithm/partial_sort
18///
19/// \ingroup algorithm
20template <typename RandomIt, typename Compare>
21constexpr auto partial_sort(RandomIt first, RandomIt middle, RandomIt last, Compare comp) -> void
22{
23 // TODO: Improve. Currently forwards to regular sort.
24 etl::ignore_unused(middle);
25 etl::sort(first, last, comp);
26}
27
28template <typename RandomIt>
29constexpr auto partial_sort(RandomIt first, RandomIt middle, RandomIt last) -> void
30{
31 etl::ignore_unused(middle);
32 etl::sort(first, last);
33}
34
35} // namespace etl
36
37#endif // TETL_ALGORITHM_PARTIAL_SORT_HPP
constexpr auto partial_sort(RandomIt first, RandomIt middle, RandomIt last, Compare comp) -> void
Rearranges elements such that the range [first, middle) contains the sorted middle - first smallest e...
Definition partial_sort.hpp:21
Definition adjacent_find.hpp:9
constexpr auto partial_sort(RandomIt first, RandomIt middle, RandomIt last) -> void
Definition partial_sort.hpp:29