//-----------------------------------------------------------------------------
#include <iostream.h>
//----Include the cpp so g++ copes with templates
#include "linkedlistclass.cpp"
//-----------------------------------------------------------------------------
int main(void) {

linkedlist<int> IntLL;
linkedlistiterator<int> IntLLI(IntLL);

cout << "List is ";
IntLL.Dump();
cout << endl;

IntLL.AddAtStart(1);
IntLL.AddAtStart(2);
IntLL.AddAtStart(3);
IntLL.AddAtStart(4);

cout << "List is ";
IntLL.Dump();
cout << endl;

IntLL.AddAtEnd(5);
IntLL.AddAtEnd(6);

cout << "List is ";
IntLL.Dump();
cout << endl;

IntLL.DeleteAtStart();
IntLL.DeleteAtEnd();

cout << "Iterator has a look forward" << endl;
IntLLI.ToStart();
cout << IntLLI.CurrentData() << " ";
while (IntLLI.NextNodeExists()) {
    ++IntLLI;
    cout << IntLLI.CurrentData() << " ";
    }
cout << " and adds something before and after" << endl;
IntLLI.AddBefore(7);
IntLLI.AddAfter(8);

cout << "Iterator has a look backwards" << endl;
IntLLI.ToEnd();
cout << IntLLI.CurrentData() << " ";
while (IntLLI.PreviousNodeExists()) {
    --IntLLI;
    cout << IntLLI.CurrentData() << " ";
    }
cout << " and adds something before and after" << endl;
IntLLI.AddBefore(9);
IntLLI.AddAfter(10);

cout << "List is ";
IntLL.Dump();
cout << endl;

cout << endl << "Look at the end data ... "
     << "First: " << IntLL.GetFirstNodeData() << " "
     << "Last:  " << IntLL.GetLastNodeData() << endl;

cout << "Move iterator to start, delete next" << endl;
IntLLI.ToStart();
IntLLI.DeleteNext();
cout << "List is ";
IntLL.Dump();
cout << endl;

cout << "Set start node data" << endl;
IntLLI.SetCurrentData(11);
cout << "List is ";
IntLL.Dump();
cout << endl;

//-----This causes an error of course
// cout << "About to try delete" << endl;
// IntLLI.DeletePrevious();

cout << "Delete the list" << endl;
while (!IntLL.Empty()) {
    cout << "Still got " << IntLL.GetFirstNodeData() << endl;
    IntLL.DeleteAtStart();
    }
    
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
