ADS
Algorithms and Data Structures
Toggle main menu visibility
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
"
54
#include "
ADS/priority/DaryHeap.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
68
namespace
ADS
69
{
70
96
template
<
class
T ,
class
C = std::less<> >
97
std::vector< std::vector< T > >
98
replacementSelection
(
const
std::vector< T > & input , std::size_t M ,
99
C less = C() );
100
126
template
<
class
T ,
class
C = std::less<> >
127
std::vector< T >
polyphaseMerge
( std::vector< std::vector< T > > runs ,
128
std::size_t tapes , C less = C() ,
129
std::size_t * phases =
nullptr
);
130
141
template
<
class
T ,
class
C = std::less<> >
142
std::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
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
DaryHeap.h
A -ary heap of plain items, beyond the book: the heap of section 10.1 with children per node in a ve...
Sorted.h
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
ADS::polyphaseMerge
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
ADS::externalSort
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()
ADS::replacementSelection
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
ADS
Definition
ADT.h:96
ADS
sort
ExternalSort.h
Generated by
1.17.0