Ejemplo n.º 1
0
void task3() {
  CircularList<int> clist;  
  cout << clist << endl;
  clist.insert(0,8);
  cout << clist << endl;
  clist.insert(1,5);
  cout << clist << endl;
  clist.insert(2,4);
  cout << clist << endl;
  clist.insert(0,0);
  cout << clist << endl;
  clist.insert(3,7);
  cout << clist << endl;
  clist.insert(5,9);
  cout << clist << endl;

  try { clist.insert(10,99); } catch (const char * e) { cout << e << endl; }

  cout << endl;
  
  CircularList<int> clist2(clist); 

  cout << clist.remove(5) << ": " << clist <<  endl;
  cout << clist.remove(1) << ": " << clist << endl;
  cout << clist.remove(0) << ": " << clist << endl;;

  cout << endl;

  cout << clist2 << endl;
  clist = clist2;
  clist2.clear();
  if(clist2.isEmpty()) cout << "Clear works correctly" << endl;
  cout << clist2 << endl;
  cout << clist << endl;
  cout << endl;

  CircularList<int> * cPtr = clist.clone();
  cout << *cPtr << endl;
  cout << cPtr->get(3) << " " << cPtr->get(0) << " " << cPtr->get(5) << endl;
  cout << *cPtr << endl;
  delete cPtr;
}