#include "SortLinkedList.h" #ifdef USE_DOT_H #include #else #include using namespace std; #endif // Simple print function. template void printList( const LList & theList ) { if( theList.isEmpty( ) ) cout << "Empty list" << endl; else { LListItr itr = theList.first( ); for( ; !itr.isPastEnd( ); itr.advance( ) ) cout << itr.retrieve( ) << " "; } cout << endl; } // Test program. int main( ) { LList theList; LListItr theItr = theList.zeroth( ); int i; printList( theList ); for( i = 0; i < 10; i++ ) { theList.insert( i, theItr ); printList( theList ); theItr.advance( ); } for( i = 0; i < 10; i += 2 ) theList.remove( i ); for( i = 0; i < 10; i++ ) if( ( i % 2 == 0 ) != ( theList.find( i ).isPastEnd( ) ) ) cout << "Find fails!" << endl; cout << "Finished deletions" << endl; printList( theList ); cout << "A copy" << endl; LList list2; list2 = theList; printList( list2 ); list2 = LList( ); cout << "The original and an empty list" << endl; printList( theList ); printList( list2 ); cout << "Sorted list3" << endl; SortedLList list3; list3.insert( 3 ); list3.insert( 1 ); list3.insert( 7 ); list3.insert( 5 ); list3.insert( 9 ); printList( list3 ); return 0; }