//-------------------------------------------------------------------- // // Laboratory 14 tst14std.cpp // // Test program for the standard deviation operation in the Hash Table ADT // //-------------------------------------------------------------------- #include #include #include #include #include "hashtbl.cpp" using namespace std; struct Data { public: void setKey ( string newKey ) { key = newKey; } string getKey () const { return key; } int hash(const string str) const { // Uncomment each of these as you try them out. //----------------------- // Hash Algorithm 1 //----------------------- return 0; //----------------------- // Hash Algorithm 2 //----------------------- // return int(str[0])*10 + str.length(); //----------------------- // Hash Algorithm 3 //----------------------- // double val = 0; // for (int i=0; i testTbl(64); Data testData; string key; ifstream data("std-dev.dat"); if( ! data ) { cerr << "Error opening 'std-dev.dat'" << endl; } else { while( data >> key ) { testData.setKey( key ); testTbl.insert( testData ); } testTbl.showStructure(); cout << endl << endl; cout << "The standard deviation is " << testTbl.stdDeviation() << endl; } }