ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
RunSorts.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*---------------------------- File RunSorts.h -----------------------------*/
3
/*--------------------------------------------------------------------------*/
66
/*--------------------------------------------------------------------------*/
67
/*----------------------------- DEFINITIONS --------------------------------*/
68
/*--------------------------------------------------------------------------*/
69
70
#ifndef __ADS_RunSorts
71
#define __ADS_RunSorts
72
/* self-identification: #endif constant */
73
74
/*--------------------------------------------------------------------------*/
75
/*------------------------------ INCLUDES ----------------------------------*/
76
/*--------------------------------------------------------------------------*/
77
78
#include "
ADS/Contract.h
"
79
#include "
ADS/sort/Sorted.h
"
80
81
#include <algorithm>
82
#include <cstddef>
83
#include <functional>
84
#include <iterator>
85
#include <type_traits>
86
#include <utility>
87
#include <vector>
88
89
/*--------------------------------------------------------------------------*/
90
/*--------------------------- NAMESPACE ------------------------------------*/
91
/*--------------------------------------------------------------------------*/
92
93
namespace
ADS
94
{
95
138
template
<
SortStore
Store ,
139
class
T = std::ranges::range_value_t< std::remove_cvref_t< Store > > ,
140
class
C = std::less<> >
141
void
powerSort
( Store && A , C less = C() , std::size_t * runs =
nullptr
);
142
144
template
<
class
T ,
class
C = std::less<> >
145
void
powerSort
( std::vector< T > & A , C less = C() ,
146
std::size_t * runs =
nullptr
);
147
148
/*--------------------------------------------------------------------------*/
149
/*------------------------- THE SORTS OF A RANGE ---------------------------*/
150
/*--------------------------------------------------------------------------*/
151
156
template
<
SortRange
R ,
class
... P >
157
requires
requires
( std::vector< std::ranges::range_value_t< R > > & v ,
158
P &&... p )
159
{
powerSort
( v , std::forward< P >( p )... ); }
160
decltype
( auto )
powerSort
( R && A , P &&... p )
161
{
162
const
auto
f = [ & ](
auto
& v ) ->
decltype
(
auto
) {
163
return
(
powerSort
( v , std::forward< P >( p )... ) );
164
};
165
return
( detail::sortRange( A , f ) );
166
}
167
168
/*--------------------------------------------------------------------------*/
169
170
}
// end( namespace ADS )
171
172
/*--------------------------------------------------------------------------*/
173
/*-------------------------- IMPLEMENTATION --------------------------------*/
174
/*--------------------------------------------------------------------------*/
175
176
#include "ADS/sort/impl/RunSorts.tpp"
177
178
/*--------------------------------------------------------------------------*/
179
180
#endif
/* RunSorts.h included */
181
182
/*--------------------------------------------------------------------------*/
183
/*-------------------------- End File RunSorts.h ---------------------------*/
184
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Sorted.h
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
ADS::SortRange
a range that the sorts take beside std::vector and std::span: random access, sized,...
Definition
Sorted.h:153
ADS::SortStore
the storage on which the sorts work in place, by reference: a std::vector or a std::span of its items...
Definition
Sorted.h:178
ADS::powerSort
void powerSort(Store &&A, C less=C(), std::size_t *runs=nullptr)
Powersort; the number of runs found goes to *runs, if given.
ADS
Definition
ADT.h:96
ADS
sort
RunSorts.h
Generated by
1.17.0