20-CS-122-001 Computer Science II Spring 2012
Doubly Linked List Class

Virtual functions, classes, inheritance, lists, queues, stacks, applications

Prev      Next      Lectures      list.2.h      list.2.cc

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

bool find (void *item, void *what) {  return *(int *)item == *(int *)what; }

void disp (void *item) {  cout << *(int *)item;  }

int main () {
   List *l = new List(find, disp);
   l->add_frnt(new int(2));
   l->add_frnt(new int(4));
   l->add_frnt(new int(6));
   l->add_rear(new int(1));
   l->add_rear(new int(9));
   l->add_rear(new int(8));
   cout << l;
   l->movetofront(new int(1));
   cout << l;
   l->movetorear(new int(4));
   cout << l;
   l->movetorear(new int(1));
   cout << l;
   l->remove(new int(9));
   cout << l;
}