We can also build a FLOAT_DLLIST object. This tests the float instantiation:
{
float input1[10] = {1.,2.,3.,4.,5.,11.,7.,8.,9.,10.};
float input2[6] = {10.,20.,30.,40.,50.,60.};
float c1 = 11.0;
float c2 = 30.0;
float c3 = 17.0;
float c4 = 10.0;
float c5 = 3.0;
char *name[4] = {"floatQaitlin","floatQuinn","floatJim","floatPauli"};
cout << "Instantiating List Qaitlin" << endl;
FLOAT_DLLIST Qaitlin(name[0]);
cout << endl << "Building Qaitlin List" << endl;
Qaitlin.build_list(input1,size1);
cout << "Qaitlin has " << Qaitlin.get_number_elements() << " elements";
cout << endl;
cout << endl << "Qaitlin = " << endl << Qaitlin << endl;
cout << endl << "Delete the element " << c1 << endl;
Qaitlin.delete_element(c1);
cout << endl << "Qaitlin = " << endl << Qaitlin << endl;
cout << endl << "Insert element " << c2 << "after "
<< c5 << endl;
Qaitlin.insert_after(c5,c2);
cout << endl << "Qaitlin = " << Qaitlin;
cout << endl << "Insert element " << c4 << "before "
<< c3 << endl;
Qaitlin.insert_before(c3,c4);
cout << endl << "Qaitlin = " << Qaitlin;
cout << "Qaitlin has " << Qaitlin.get_number_elements() << " elements";
cout << endl << "Sort the list Qaitlin." << endl;
Qaitlin.mergesort();
cout << endl << Qaitlin << endl;
cout << "Copy Constructor Test: Copy Qaitlin into Quinn:" << endl;
FLOAT_DLLIST Quinn = Qaitlin;
cout << "Quinn = " << Quinn;
cout << "Instantiating List Quinn" << endl;
FLOAT_DLLIST Jim(name[2]);
cout << endl << "Building Jim List" << endl;
Jim.build_list(input2,size2);
cout << "Jim has " << Jim.get_number_elements() << " elements";
cout << endl;
cout << endl << "Jim = " << endl << Quinn << endl;
cout << endl << "Overloaded Equal Test: Jim = Qaitlin" << endl;
Jim = Qaitlin;
cout << endl << "Jim = " << endl << Quinn << endl;
cout << "Test Overloaded Input Operator: " << endl;
FLOAT_DLLIST Pauli(name[3]);
cin >> Pauli;
cout << "Pauli = " << Pauli;
return 0;
}
Instantiating List Qaitlin Building Qaitlin List Qaitlin has 10 elements Qaitlin = 1<-->2<-->3<-->4<-->5<-->11<-->7<-->8<-->9<-->10. Delete the element 11 Qaitlin = 1<-->2<-->3<-->4<-->5<-->7<-->8<-->9<-->10. Insert element 30after 3 Qaitlin = 1<-->2<-->3<-->30<-->4<-->5<-->7<-->8<-->9<-->10. Insert element 10before 17 The element 17 is not in the list. 17 is not in the list, so do not insert. Qaitlin = 1<-->2<-->3<-->30<-->4<-->5<-->7<-->8<-->9<-->10. Qaitlin has 10 elements Sort the list Qaitlin. 1<-->2<-->3<-->4<-->5<-->7<-->8<-->9<-->10<-->30. Copy Constructor Test: Copy Qaitlin into Quinn: Quinn = 1<-->2<-->3<-->4<-->5<-->7<-->8<-->9<-->10<-->30. Instantiating List Quinn Building Jim List Jim has 6 elements Jim = 1<-->2<-->3<-->4<-->5<-->7<-->8<-->9<-->10<-->30. Overloaded Equal Test: Jim = Qaitlin Jim = 1<-->2<-->3<-->4<-->5<-->7<-->8<-->9<-->10<-->30. Test Overloaded Input Operator: Please Enter the element which terminates input: 999 12.03 45.789 999 Pauli = 12.03<-->45.789.