// ASU CSE310 Assignment #5 Spring 2023 // Name of Author:
// ASU ID:
// Description: this is the main program that reads input from a text file,
// it then call hash functions to execute hash commands given in the input.
// —- is where you need to add your own code
/*****************************************************************************
//(1)Describe here what is your hash function? How do you get an input Employee // object’s hash value.
//(2)Did your hash function work well? For each of the four test cases, list here // your hash function’s performance ratio and the longest LinkedList size. //(3)If you had to change your hash function to reduce the number of collisions, // how will you change it?
******************************************************************************
**/
#include “Hash.h”
#include <sstream>
using namespace std;
//This function used to get an Employee key which is the combination of firstName, lastName and id
void getKey(string oneLine, string&firstName, string& lastName, int& id);
int main()
{
int size = 0 ;
int numOfCommand = 0;
string firstName, lastName;
int id; double salary;
//declare any other necessary variables here
//—-
cout << “Enter the size of the hash table: “; cin >> size; cin.ignore(20, ‘\n’);
//Instantiate the hash table with the relevant number of slots
//—-
do {
//use this do..while loop to repeatly get one line Employee info. and extract tokens
//create one Employee object and insert it inside the hashTable until seeing the message
//”InsertionEnd”, then terminate
//—-
//—-
} while(true);
cout << “\nEnter number of commands: “; //***need to comment out in submitting cin >> numOfCommand;
cin.ignore(20, ‘\n’);
for(int i= 0; i < numOfCommand; i++)
{
//get one line command, extract the first token, if only one token if(firstToken.compare(“hashDisplay”) == 0)
{
//—-
//—-
}
else //more than one tokens, check the command name, extract the remaining tokens
{
//—-
//—-
if(command.compare(“hashSearch”)==0)
//—-
//—-
else if(command.compare(“hashDelete”)==0)
//—-
//—-
else if(command.compare(“hashLoadFactor”)==0)
//—- //—- else
cout<<“Invalid command”<<endl;
}
} //end for loop
return 0;
}
//****************************************************************************
************
//Given one line, this function extracts firstName, lastName, id info. of an Employee
//This function is completed and given here as a study guide for extracting tokens void getKey(string oneLine, string& firstName, string& lastName, int& id)
{
string delimiter = “,”; int pos=oneLine.find(delimiter); string token = oneLine.substr(0,pos); string command = token;
oneLine.erase(0, pos+delimiter.length());
pos=oneLine.find(delimiter); token = oneLine.substr(0,pos); firstName = token;
oneLine.erase(0, pos+delimiter.length());
pos=oneLine.find(delimiter); token = oneLine.substr(0,pos); lastName = token;
oneLine.erase(0, pos+delimiter.length());
pos=oneLine.find(delimiter); token = oneLine.substr(0,pos); id = stoi(token);
oneLine.erase(0, pos+delimiter.length());
}
Need help with your own assignment?
Our expert writers can help you apply everything you've just read — to your actual assignment.
Get Expert Help Now →