41 #define SORT_DEBUG if (0)
84 template <
class T,
class Compare>
86 Compare *cmp,
int deleteInputStream = 0)
92 assert(instream && outstream && cmp);
95 if (instreamLength == 0) {
97 if (deleteInputStream) {
105 cout <<
"AMI_sort: sorting stream" <<
name <<
", len=" << instreamLength
115 if (deleteInputStream) {
119 if (runList->
length() == 0) {
121 fprintf(stderr,
"ami_sort: Error - no runs created!\n");
123 cout <<
"ami_sort: instream = " <<
name << endl;
128 else if (runList->
length() == 1) {
137 *outstream = multiMerge<T, Compare>(runList, cmp);
146 cout <<
"AMI_sort: done" << endl << endl;
151 assert((*outstream)->stream_len() == instreamLength);
155 template <
class T,
class Compare>
168 cout <<
"reading: " << *crt << endl;
172 cout <<
"reading: " << *crt << endl;
173 if (cmp.compare(*prev, *crt) != -1)
int isSorted(AMI_STREAM< T > *str, Compare cmp)
AMI_err AMI_sort(AMI_STREAM< T > *instream, AMI_STREAM< T > **outstream, Compare *cmp, int deleteInputStream=0)
queue< char * > * runFormation(AMI_STREAM< T > *instream, Compare *cmp)
AMI_err name(char **stream_name)
AMI_err seek(off_t offset)
AMI_err read_item(T **elt)
unsigned int length() const
#define assert(condition)