ADS
Algorithms and Data Structures
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"
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
134namespace ADS
135{
136
186template< SortStore Store , VectorKey T = std::ranges::range_value_t<
187 std::remove_cvref_t< Store > > >
188void learnedSort( Store && A );
189
191template< VectorKey T >
192void learnedSort( std::vector< T > & A );
193
194namespace detail
195{
196
199template< SortStore Store , VectorKey T = std::ranges::range_value_t<
200 std::remove_cvref_t< Store > > >
201bool learnedSortIf( Store && A );
202
203} // end( namespace detail )
204
205/*--------------------------------------------------------------------------*/
206/*------------------------- THE SORTS OF A RANGE ---------------------------*/
207/*--------------------------------------------------------------------------*/
208
213template< 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 }
219decltype( 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/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The sorts by the digits of the keys, beyond the book (which has Counting Sort and Pigeonhole Sort,...
The in-place super scalar samplesort, beyond the book: sampleSort() splits the vector into up to 256 ...
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
The quicksort in the lanes of the vector registers, beyond the book: vectorQuickSort() sorts integers...
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
the types that vectorQuickSort() sorts: integers and floating point numbers of 32 or 64 bits
Definition VectorQuickSort.h:178
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...
Definition ADT.h:96