template <class List_entry>
void Sortable_list<List_entry>::sort_interval(int start, int increment)
/*
Post: the sublist defined by "increment" has been sorted?
Uses: Methods for the class List_entry; the contiguous List implementation of
Chapter 6
--supposed to be a "modified insertion sort" ...
*/
{
char anykey;
int first_unsorted; // position of first unsorted entry
int position; // searches sorted part of list
int current; // holds the entry temporarily removed from list
//cout<<"inside the sort_interval\n";
//cout<<"increment is " <<increment;
//cin>>anykey;
for (first_unsorted = start+increment; first_unsorted < count; first_unsorted=(first_unsorted+increment))
if (entry[first_unsorted] < entry[first_unsorted - increment]) {
// cout<<"inside the if entry ["<<first_unsorted <<"] > entry[ " <<first_unsorted-increment <<"] (\n";
//cin>>anykey;
position = first_unsorted;
cout<<" position is " <<position;
current = entry[first_unsorted];
// cout<<"first_unsorted is " <<first_unsorted <<endl;
// Pull unsorted entry out of the list.
do { // Shift all entries until the proper position is found.
cout<<"doodwhile?\n";
// cin>>anykey;
entry[position] = entry[position - increment];
cout<<"testing " <<endl;
// cin>>anykey;
position=(position-increment); // position is empty.
// cout<<"testing after " <<endl;
// cin>>anykey;
//cout<<" position is " <<position;
//cout<<"first_unsorted is " <<first_unsorted;
//cout<<"increment is " <<increment <<endl;
} while (position > start && entry[position-increment] > current);
cout<<"dood?\n";
// cin>>anykey;
entry[position] = current;
}
}