ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
TreeSort.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*---------------------------- File TreeSort.h -----------------------------*/
3
/*--------------------------------------------------------------------------*/
28
/*--------------------------------------------------------------------------*/
29
/*----------------------------- DEFINITIONS --------------------------------*/
30
/*--------------------------------------------------------------------------*/
31
32
#ifndef __ADS_TreeSort
33
#define __ADS_TreeSort
34
/* self-identification: #endif constant */
35
36
/*--------------------------------------------------------------------------*/
37
/*------------------------------ INCLUDES ----------------------------------*/
38
/*--------------------------------------------------------------------------*/
39
40
#include "
ADS/Contract.h
"
41
#include "
ADS/sort/Sorted.h
"
42
#include "
ADS/tree/SearchTree.h
"
43
44
#include <algorithm>
45
#include <concepts>
46
#include <cstddef>
47
#include <functional>
48
#include <utility>
49
#include <vector>
50
51
/*--------------------------------------------------------------------------*/
52
/*--------------------------- NAMESPACE ------------------------------------*/
53
/*--------------------------------------------------------------------------*/
54
55
namespace
ADS
56
{
57
77
template
<
RankStore
Store ,
78
std::totally_ordered T = std::ranges::range_value_t<
79
std::remove_cvref_t< Store > > >
80
void
treeSort
( Store && A ,
bool
balanced =
true
);
81
83
template
< std::totally_ordered T >
84
void
treeSort
( std::vector< T > & A ,
bool
balanced =
true
);
85
86
/*--------------------------------------------------------------------------*/
87
/*------------------------- THE SORTS OF A RANGE ---------------------------*/
88
/*--------------------------------------------------------------------------*/
89
94
template
<
SortRange
R ,
class
... P >
95
requires
requires
( std::vector< std::ranges::range_value_t< R > > & v ,
96
P &&... p )
97
{
treeSort
( v , std::forward< P >( p )... ); }
98
decltype
( auto )
treeSort
( R && A , P &&... p )
99
{
100
const
auto
f = [ & ](
auto
& v ) ->
decltype
(
auto
) {
101
return
(
treeSort
( v , std::forward< P >( p )... ) );
102
};
103
return
( detail::sortRange( A , f , f ) );
104
}
105
106
/*--------------------------------------------------------------------------*/
107
108
}
// end( namespace ADS )
109
110
/*--------------------------------------------------------------------------*/
111
/*-------------------------- IMPLEMENTATION --------------------------------*/
112
/*--------------------------------------------------------------------------*/
113
114
#include "ADS/sort/impl/TreeSort.tpp"
115
116
/*--------------------------------------------------------------------------*/
117
118
#endif
/* TreeSort.h included */
119
120
/*--------------------------------------------------------------------------*/
121
/*-------------------------- End File TreeSort.h ---------------------------*/
122
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
SearchTree.h
The binary search tree (ABR) and the Red-Black tree of the book, as a DICTIONARY [see ADT....
Sorted.h
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
ADS::RankStore
the storage on which the sorts of the book work in place, which read the items by their ranks only: a...
Definition
Sorted.h:184
ADS::SortRange
a range that the sorts take beside std::vector and std::span: random access, sized,...
Definition
Sorted.h:153
ADS::treeSort
void treeSort(Store &&A, bool balanced=true)
the tree sort on a Red-Black tree, or on a search tree with no balance if balanced is false
ADS
Definition
ADT.h:96
ADS
sort
TreeSort.h
Generated by
1.17.0