Iros
Loading...
Searching...
No Matches
sort.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
di/container/algorithm/make_heap.h
"
4
#include "
di/container/algorithm/sort_heap.h
"
5
6
namespace
di::container
{
7
namespace
detail
{
8
struct
SortFunction
{
9
template
<concepts::RandomAccessIterator It, concepts::SentinelFor<It> Sent,
typename
Comp = function::Compare,
10
typename
Proj = function::Identity>
11
requires
(
concepts::Sortable<It, Comp, Proj>
)
12
constexpr
auto
operator
()(It first, Sent last, Comp comp = {}, Proj
proj
= {})
const
-> It {
13
// FIXME: consider using quick sort instead of heap sort.
14
container::make_heap
(first, last,
util::ref
(comp),
util::ref
(
proj
));
15
return
container::sort_heap
(first, last,
util::ref
(comp),
util::ref
(
proj
));
16
}
17
18
template
<
concepts::RandomAccessContainer
Con,
typename
Comp =
function::Compare
,
19
typename
Proj =
function::Identity
>
20
requires
(
concepts::Sortable<meta::ContainerIterator<Con>
, Comp, Proj>)
21
constexpr
auto
operator
()(Con&&
container
, Comp comp = {}, Proj
proj
= {})
const
22
->
meta::BorrowedIterator<Con>
{
23
return
(*
this
)(
container::begin
(
container
),
container::end
(
container
),
util::ref
(comp),
util::ref
(
proj
));
24
}
25
};
26
}
27
28
constexpr
inline
auto
sort
=
detail::SortFunction
{};
29
}
30
31
namespace
di
{
32
using
container::sort
;
33
}
di::concepts::RandomAccessContainer
Definition
random_access_container.h:8
di::concepts::Sortable
Definition
sortable.h:11
make_heap.h
di::container::detail
Definition
sequence.h:13
di::container
Definition
sequence.h:12
di::container::make_heap
constexpr auto make_heap
Definition
make_heap.h:34
di::container::sort
constexpr auto sort
Definition
sort.h:28
di::container::end
constexpr auto end
Definition
end.h:47
di::container::sort_heap
constexpr auto sort_heap
Definition
sort_heap.h:38
di::container::begin
constexpr auto begin
Definition
begin.h:44
di::meta::BorrowedIterator
Conditional< concepts::BorrowedContainer< Con >, ContainerIterator< Con >, container::Dangling > BorrowedIterator
Definition
borrowed_iterator.h:11
di::util::ref
constexpr auto ref
Definition
reference_wrapper.h:98
di
Definition
zstring_parser.h:9
di::proj
constexpr auto proj
Definition
proj.h:59
sort_heap.h
di::container::detail::SortFunction
Definition
sort.h:8
di::function::Compare
Definition
compare.h:8
di::function::Identity
Definition
identity.h:7
libs
di
include
di
container
algorithm
sort.h
Generated by
1.13.0