Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python

C++


JAVA
PHP
SQL
Alice

LList


listtest.cpp

// A program to test llist class
//
#include "llist.h"
#include <iostream>
using namespace std;
//-----------------------------------------------------------------------
int main() {

llist L;

node *x=new node;
x->key=11;

L.insert_at_head(x);

x=new node;
x->key=456;

L.insert_at_head(x);
x=new node;
x->key=453;

L.insert_at_head(x);
x=new node;
x->key=234;

L.insert_at_head(x);
x=new node;
x->key=2;

L.insert_at_head(x);

x=new node;
x->key=34;

node *y=L.find(11);
L.insert_after(y,x);

//cout<< L.head_value()<<"\n"; 

cout<< L.remove(y)<<"\n";

y=L.find(2);
cout<<L.remove(y)<<"\n";


//cout<< L.head_value()<<"\n"; 

//cout<<L.find(17)<<"\n";
//cout<<L.find(234)<<"\n";

llist T;
T=L;

y=L.find(456);
L.remove(y);

if(L.find(456)!=NULL)
  cout<<"456 found\n";
else
  cout<<"456 not found\n";

if(T.find(456)!=NULL)
  cout<<"456 found\n";
else
  cout<<"456 not found\n";

if(L.find(453)!=NULL)
  cout<<"453 found\n";
else
  cout<<"453 not found\n";

if(T.find(453)!=NULL)
  cout<<"453 found\n";
else
  cout<<"453 not found\n";

return 0; 
}