ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ExternalSort.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File ExternalSort.h ---------------------------*/
3/*--------------------------------------------------------------------------*/
41/*--------------------------------------------------------------------------*/
42/*----------------------------- DEFINITIONS --------------------------------*/
43/*--------------------------------------------------------------------------*/
44
45#ifndef __ADS_ExternalSort
46 #define __ADS_ExternalSort
47/* self-identification: #endif constant */
48
49/*--------------------------------------------------------------------------*/
50/*------------------------------ INCLUDES ----------------------------------*/
51/*--------------------------------------------------------------------------*/
52
53#include "ADS/Contract.h"
55#include "ADS/sort/Sorted.h"
56
57#include <algorithm>
58#include <cstddef>
59#include <deque>
60#include <functional>
61#include <utility>
62#include <vector>
63
64/*--------------------------------------------------------------------------*/
65/*--------------------------- NAMESPACE ------------------------------------*/
66/*--------------------------------------------------------------------------*/
67
68namespace ADS
69{
70
96template< class T , class C = std::less<> >
97std::vector< std::vector< T > >
98replacementSelection( const std::vector< T > & input , std::size_t M ,
99 C less = C() );
100
126template< class T , class C = std::less<> >
127std::vector< T > polyphaseMerge( std::vector< std::vector< T > > runs ,
128 std::size_t tapes , C less = C() ,
129 std::size_t * phases = nullptr );
130
141template< class T , class C = std::less<> >
142std::vector< T > externalSort( const std::vector< T > & input , std::size_t M ,
143 std::size_t tapes , C less = C() );
144
145/*--------------------------------------------------------------------------*/
146
147} // end( namespace ADS )
148
149/*--------------------------------------------------------------------------*/
150/*-------------------------- IMPLEMENTATION --------------------------------*/
151/*--------------------------------------------------------------------------*/
152
153#include "ADS/sort/impl/ExternalSort.tpp"
154
155/*--------------------------------------------------------------------------*/
156
157#endif /* ExternalSort.h included */
158
159/*--------------------------------------------------------------------------*/
160/*------------------------ End File ExternalSort.h -------------------------*/
161/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
A -ary heap of plain items, beyond the book: the heap of section 10.1 with children per node in a ve...
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
std::vector< T > polyphaseMerge(std::vector< std::vector< T > > runs, std::size_t tapes, C less=C(), std::size_t *phases=nullptr)
the polyphase merge of the runs on tapes; the phases go to *phases, if given
std::vector< T > externalSort(const std::vector< T > &input, std::size_t M, std::size_t tapes, C less=C())
the sort of input by replacementSelection() and then polyphaseMerge()
std::vector< std::vector< T > > replacementSelection(const std::vector< T > &input, std::size_t M, C less=C())
the runs of the input made by replacement selection with items in memory
Definition ADT.h:96