#include <iostream>
#include <cstdlib>
#include <cassert>
#include "CLList.h"

namespace uprm_icom4035 {
  
  //////////////// DO NOT MODIFY THESE FUNCTIONS //////////////////////////////
  template <typename Item>
  void CLList<Item>::print_list(ostream& out) const{
    cl_list_node<Item> *temp = NULL;
    
    // print each data value on a separate line
    for (temp = header->next; temp != header; temp = temp->next){
      out << temp->data << endl;
    }
  } 
  

  // Return the element at the current location of the iterator
  // Note: This function will throw a string exception if the 
  // Iterator is not on a valid node with data (i.e. the header)
  template <typename Item>
  Item& CLLIterator<Item>::get_data() const {
    if (has_data()){
      return curr->data;
    }
    else {
      string msg = "CLLIterator<Item>::get_data()Error: Iterator has no data to return.";
      throw msg;
    }
  }

  // Constructor for the iterator
  template <typename Item>
  CLLIterator<Item>::CLLIterator(cl_list_node<Item>* hdr, 
				 cl_list_node<Item>* tail):Iterator<Item>(){
    this->hdr = hdr;
    this->tail = tail;
    this->curr = hdr;
  }
  
  
  //////////////////////////////////////////////////////////////////////////

  /************* START ADDING FOR CODE FROM HERE **************************/
  
}
