Listing 7: Skiplist test program
#include <iostream.h> #include <strstrea.h> //or strstream.h #include "skiplist.h" // a test class struct person { char *name; int age; }; void main() { int i; person *found; static person people[6] = { {"John", 14}, {"Joe", 12}, {"Fred", 2}, {"Julie", 3}, {"Jasman", 20}, {"Fran", 11} }; Skiplist<person,int> list_o_people; // // add people to the list // for( i = 0; i < 6; i ++ ) { list_o_people.insert( &people[i],<br> people[i].age ); } // // find person who is 11 // found = list_o_people.find(11); if( found != NULL ) cout << found->name << " is 11 " << endl; else cout << "Search failed" << endl; // // remove the 20 year old // found = list_o_people.remove( 20 ); if( found != NULL ) cout << "Removed " << found->name << endl; else cout << "Removed failed" << endl; }