// File: Application.cpp // Test the template ordered linked list object type #include #include #include "LinkedList.h" int main() { LinkedList l1, l2; int x; // build a couple of lists for (x = 0; x < 30; x += 3 ) { l1.orderedInsert( x ); } cout << "list1: " << l1 << endl; for (x = 0; x < 25; x += 2 ) { l2.orderedInsert( x ); } cout << "Original lists" << endl; cout << "list1: " << l1 << endl; cout << "list2: " << l2 << endl; cout << endl; LinkedList l3( l1 );// copy LinkedList 1 using a copy constructor LinkedList l4; // copy LinkedList 2 using an assignment operator l4 = l2; cout << "Copies of the LinkedLists" << endl; cout << "LinkedList3: " << l3 << endl; cout << "LinkedList4: " << l4 << endl; cout << endl; cout << "15 is " << (l1.find(15) ? "" :"not ") << "in LinkList 1" << endl; cout << "16 is " << (l1.find(16) ? "" :"not ") << "in LinkList 1" << endl; cout << endl; cout << "remove item 12 from LinkedList 1" << endl; cout << "before: " << l1 << endl; l1.remove(12); cout << "after: " << l1 << endl; cout << endl; /* // uncomment to test your code l3 = l1 + l2; cout << "Concatenated list (l1+l2): " << l3 << endl; cout << endl; l3.sort(); cout << "Ordered list: " << l3 << endl; */ // Test out some functions // The [] operator cout << "l1[4] is "; if (l1[4]) cout << *(l1[4]) << endl; else cout << "out of range" << endl; cout << "l1[11] is "; if (l1[11]) cout << *(l1[11]) << endl; else cout << "out of range" << endl; // Count nodes in LinkedList (it calls the private function) cout << "There are " << l1.countNodesInList() << " nodes in l1\n"; cout << "LinkedList1: " << l1 << endl; l1.mystery(); cout << "Post-mystery LinkedList1: " << l1 << endl; return(0); }