ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
LearnedSort.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*--------------------------- File LearnedSort.h ---------------------------*/
3
/*--------------------------------------------------------------------------*/
102
/*--------------------------------------------------------------------------*/
103
/*----------------------------- DEFINITIONS --------------------------------*/
104
/*--------------------------------------------------------------------------*/
105
106
#ifndef __ADS_LearnedSort
107
#define __ADS_LearnedSort
108
/* self-identification: #endif constant */
109
110
/*--------------------------------------------------------------------------*/
111
/*------------------------------ INCLUDES ----------------------------------*/
112
/*--------------------------------------------------------------------------*/
113
114
#include "
ADS/Contract.h
"
115
#include "
ADS/sort/RadixSort.h
"
116
#include "
ADS/sort/SampleSort.h
"
117
#include "
ADS/sort/Sorted.h
"
118
#include "
ADS/sort/VectorQuickSort.h
"
119
120
#include <algorithm>
121
#include <array>
122
#include <bit>
123
#include <cstddef>
124
#include <cstdint>
125
#include <cstring>
126
#include <memory>
127
#include <type_traits>
128
#include <vector>
129
130
/*--------------------------------------------------------------------------*/
131
/*--------------------------- NAMESPACE ------------------------------------*/
132
/*--------------------------------------------------------------------------*/
133
134
namespace
ADS
135
{
136
186
template
<
SortStore
Store ,
VectorKey
T = std::ranges::range_value_t<
187
std::remove_cvref_t< Store > > >
188
void
learnedSort
( Store && A );
189
191
template
< VectorKey T >
192
void
learnedSort
( std::vector< T > & A );
193
194
namespace
detail
195
{
196
199
template
<
SortStore
Store ,
VectorKey
T = std::ranges::range_value_t<
200
std::remove_cvref_t< Store > > >
201
bool
learnedSortIf( Store && A );
202
203
}
// end( namespace detail )
204
205
/*--------------------------------------------------------------------------*/
206
/*------------------------- THE SORTS OF A RANGE ---------------------------*/
207
/*--------------------------------------------------------------------------*/
208
213
template
< SortRange R ,
class
... P >
214
requires
requires
( std::vector< std::ranges::range_value_t< R > > & v ,
215
P &&... p )
216
{
217
learnedSort
( v , std::forward< P >( p )... );
218
}
219
decltype
( auto )
learnedSort
( R && A , P &&... p )
220
{
221
const
auto
f = [ & ](
auto
& v ) ->
decltype
(
auto
) {
222
return
(
learnedSort
( v , std::forward< P >( p )... ) );
223
};
224
return
( detail::sortRange( A , f ) );
225
}
226
227
/*--------------------------------------------------------------------------*/
228
229
}
// end( namespace ADS )
230
231
/*--------------------------------------------------------------------------*/
232
/*-------------------------- IMPLEMENTATION --------------------------------*/
233
/*--------------------------------------------------------------------------*/
234
235
#include "ADS/sort/impl/LearnedSort.tpp"
236
237
/*--------------------------------------------------------------------------*/
238
239
#endif
/* LearnedSort.h included */
240
241
/*--------------------------------------------------------------------------*/
242
/*------------------------- End File LearnedSort.h -------------------------*/
243
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
RadixSort.h
The sorts by the digits of the keys, beyond the book (which has Counting Sort and Pigeonhole Sort,...
SampleSort.h
The in-place super scalar samplesort, beyond the book: sampleSort() splits the vector into up to 256 ...
Sorted.h
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
VectorQuickSort.h
The quicksort in the lanes of the vector registers, beyond the book: vectorQuickSort() sorts integers...
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::VectorKey
the types that vectorQuickSort() sorts: integers and floating point numbers of 32 or 64 bits
Definition
VectorQuickSort.h:178
ADS::learnedSort
void learnedSort(E &ex, Store &&A)
the vector of numbers sorted in their natural order on the threads of ex, distributed by the model o...
ADS
Definition
ADT.h:96
ADS
sort
LearnedSort.h
Generated by
1.17.0