예제 #1
0
int main()
{
  //test();
  LookupTable table; 
  // READ IN THE LIST OF KEYS HERE…
  ifstream inputFile;
  inputFile.open("input.txt");
  string line;
  
  while(getline(inputFile,line)) {
    remove(line.begin(),line.end(),' ');
    table.insert(line,createItem(line));
  }
  inputFile.close();
  table.display();

  Item i = table.retrieve("when");
  cout << "count for when is: " << i.count << endl; // should be 1

  i = table.retrieve("weather");
  cout << "count for weather is: " << i.count << endl; // should be 2

  table.remove("when");
  table.remove("weather");

  i = table.retrieve("weather");
  cout << "count for weather is: " << i.count << endl; // should  be 1
  table.display();
}
예제 #2
0
void test()
{
  LookupTable table;
  cout << "test(): inserting 'when'" << endl;
  table.insert("when", createItem("when"));        table.display();
  cout << "test(): inserting 'can'" << endl;
  table.insert("can", createItem("can"));          table.display();
  cout << "test(): inserting 'sailing'" << endl;
  table.insert("sailing", createItem("sailing"));  table.display();
  cout << "test(): inserting 'weather'" << endl;
  table.insert("weather", createItem("weather"));  table.display();

  Item i = table.retrieve("when");

  i = table.retrieve("weather");

  table.remove("when");
  table.display();
  table.remove("weather");

  i = table.retrieve("weather");

  table.display();
}