// L-12 MCS 360 Mon 20 Sep 2010 : test_mcs360_double_list.cpp

#include "mcs360_double_list.h"
#include <iostream>
using namespace std;
using namespace mcs360_double_list;

void write_with_iterator ( List<int> L )
{
   for(List<int>::Iterator item = L.begin();
       item != L.end(); ++item) // use prefix
//       item != L.end(); item++) // test postfix
      cout << "->" << *item;
   cout << endl;
}

int main()
{
   List<int> L(3);

   L.append(5);
   L.append(4);
   cout << " forward write :";
   L.write_forward();
   cout << endl;
   cout << "backward write :";
   L.write_backward();
   cout << endl;

// the next block illustrates sharing

   List<int> K = L;
   L.append(1);
   cout << " writing K after K = L :";
   K.write_forward(); cout << endl;
   cout << " writing L after K = L :";
   L.write_forward(); cout << endl;

// test iterator

   cout << "writing L with iterator : ";
   write_with_iterator(L);

   return 0;
}

