tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
nth_element.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_NTH_ELEMENT_HPP
4#define TETL_ALGORITHM_NTH_ELEMENT_HPP
5
8
9namespace etl {
10
21template <typename RandomIt, typename Compare>
22constexpr auto nth_element(RandomIt first, RandomIt nth, RandomIt last, Compare comp) -> void
23{
24 // TODO: Improve. Currently forwards to regular sort.
26 etl::sort(first, last, comp);
27}
28
29template <typename RandomIt>
30constexpr auto nth_element(RandomIt first, RandomIt nth, RandomIt last) -> void
31{
33 etl::sort(first, last);
34}
35
36} // namespace etl
37
38#endif // TETL_ALGORITHM_NTH_ELEMENT_HPP
constexpr auto nth_element(RandomIt first, RandomIt nth, RandomIt last, Compare comp) -> void
nth_element is a partial sorting algorithm that rearranges elements in [first, last) such that:
Definition nth_element.hpp:22
constexpr auto sort(RandomIt first, RandomIt last, Compare comp) -> void
Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is...
Definition sort.hpp:18
Definition adjacent_find.hpp:8
constexpr auto ignore_unused(Types &&...) -> void
Explicitly ignore arguments or variables.
Definition ignore_unused.hpp:17