TPIE

2362a60
tpie::sort_manager< T, I, M > Class Template Reference

A class of manager objects for merge sorting objects of type T. More...

#include <tpie/sort_manager.h>

Public Member Functions

 sort_manager (I *isort, M *mheap)
 
void sort (file_stream< T > *in, file_stream< T > *out, progress_indicator_base *indicator=NULL)
 Sort in stream to out stream an save in stream (uses 3x space) More...
 
void sort (file_stream< T > *in, progress_indicator_base *indicator=NULL)
 Sort in stream and overwrite unsorted input with sorted output (uses 2x space) More...
 

Detailed Description

template<class T, class I, class M>
class tpie::sort_manager< T, I, M >

A class of manager objects for merge sorting objects of type T.

We will actually use one of two subclasses of this class which use either a comparison object, or the binary comparison operator <.

Definition at line 60 of file sort_manager.h.

Member Function Documentation

template<class T , class I , class M >
void tpie::sort_manager< T, I, M >::sort ( file_stream< T > *  in,
file_stream< T > *  out,
progress_indicator_base indicator = NULL 
)

Sort in stream to out stream an save in stream (uses 3x space)

Definition at line 176 of file sort_manager.h.

References tpie::file_stream< T >::read(), and tpie::file_stream< T >::seek().

177  {
178  m_indicator = indicator;
179 
180  // if the input and output stream are the same, we only use 2x space.
181  // otherwise, we need 3x space. (input, current temp runs, output runs)
182  use2xSpace = (in == out);
183 
184  inStream = in;
185  outStream = out;
186 
187  // Basic checks that input is ok
188  if (in==NULL || out==NULL) {
189  if (m_indicator) {m_indicator->init(1); m_indicator->step(); m_indicator->done();}
190  throw exception("NULL_POINTER");
191  }
192 
193  if (inStream->size() < 2) {
194  if (m_indicator) {m_indicator->init(1); m_indicator->step(); m_indicator->done();}
195  in->seek(0);
196  if (in != out) {
197  out->seek(0);
198  if (in->size() == 1)
199  out->write(in->read());
200  }
201  return;
202  }
203 
204  // Else, there is something to sort, do it
205  start_sort();
206 }
virtual void done()
Advance the indicator to the end.
void step(stream_size_type step=1)
Record an increment to the indicator and advance the indicator.
virtual void init(stream_size_type range=0)
Initialize progress indicator.
template<class T , class I , class M >
void tpie::sort_manager< T, I, M >::sort ( file_stream< T > *  in,
progress_indicator_base indicator = NULL 
)

Sort in stream and overwrite unsorted input with sorted output (uses 2x space)

Definition at line 209 of file sort_manager.h.

References tpie::sort().

209  {
210  sort(in, in, indicator);
211 }
void sort(file_stream< T > *in, file_stream< T > *out, progress_indicator_base *indicator=NULL)
Sort in stream to out stream an save in stream (uses 3x space)
Definition: sort_manager.h:176

The documentation for this class was generated from the following file: