#include <iostream>
using namespace std;
int main ( void )
{
cList<string> list;
list.PushFront("am");
list.PushFront("I");
list.PushFront("Program");
list.PushBack("Nick Cash's");
list.PushBack("Program");
cout << "\nOriginal list:";
list.Print();
cout << "\nSize: " << list.Size() << endl;
cout << "Empty: " << (list.Empty() ? "Yes" : "No") << endl;
cout << "\nReversing...";
list.Reverse();
list.Print();
cout << "\nSize: " << list.Size() << endl;
cout << "Empty: " << (list.Empty() ? "Yes" : "No") << endl;
cout << "\nReversing again...";
list.Reverse();
list.Print();
cout << "\nSize: " << list.Size() << endl;
cout << "Empty: " << (list.Empty() ? "Yes" : "No") << endl;
cout << "\nPerforming traversal and inserting 'Awesome' after 'Nick Cash's'";
for ( cList<string>::Element* iter = list.GetStart(); iter; iter = iter->GetNext() )
{
cout << "\nData -> " << iter->data;
if ( iter->data == "Nick Cash's" )
{
cList<string>::Element* x = new cList<string>::Element;
x->data = "Awesome";
list.Insert( x, iter->GetNext() );
}
}
cout << "\n\nPerforming reverse traversal:";
for ( cList<string>::Element* iter = list.GetEnd(); iter; iter = iter->GetPrev() )
{
cout << "\nData -> " << iter->data;
}
cout << "\n\nPopping front...";
list.PopFront();
list.Print();
cout << "\nSize: " << list.Size() << endl;
cout << "Empty: " << (list.Empty() ? "Yes" : "No") << endl;
cout << "\nReadding 'Program'...";
list.PushFront("Program");
list.Print();
cout << endl << endl;
cout << "\nPopping back...";
list.PopBack();
list.Print();
cout << "\nSize: " << list.Size() << endl;
cout << "Empty: " << (list.Empty() ? "Yes" : "No") << endl;
cout << "\nReadding 'Program'...";
list.PushBack("Program");
list.Print();
cout << endl << endl;
cout << "\nDeleting 'am'...\n\n";
list.Delete("am");
cout << "\nNew list:";
list.Print();
cout << "\nSize: " << list.Size() << endl;
cout << "Empty: " << (list.Empty() ? "Yes" : "No") << endl;
cout << "\n\nErasing 'Program'...\n\n";
list.Erase("Program");
cout << "\nNew list:";
list.Print();
cout << "\nSize: " << list.Size() << endl;
cout << "Empty: " << (list.Empty() ? "Yes" : "No") << endl;
cout << "\n\nClearing list...\n\n";
list.Clear();
cout << "Size: " << list.Size() << endl;
cout << "Empty: " << (list.Empty() ? "Yes" : "No") << endl;
cin.get();
return EXIT_SUCCESS;
}