i am very new to C++ programming. I am doing my master and working on one problem given by professor. the problem is regarding performing the basic operations on binary search tree. i have one file which has below format :
I 1015291402
I 729831403
I 1005116371
F 757970570
D 1005116371
F 729831403
I 1218751282
D 1015291402
I 582339464
I 92421221
There are three basic operations Insert, Delete and Find can be done on search tree. so i need to read this file perform operation line by line. Below is the code i wrote so far.
string line;
ifstream infilesmall("inputfile_small.txt");
//ifstream infilelarge("inputfile_small.txt");
while (getline(infilesmall, line))
{
istringstream iss(line);
vector<string> tokens;
copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(tokens));
string str = ((tokens)._Myfirst)[0];
cout<< ((tokens)._Myfirst)[1];
//char operation = new char(((tokens)._Myfirst)[0]);
/*typedef void (*funcPointer)(int);
void String1Action(int arg);
void String2Action(int arg);
map<string, funcPointer> stringFunctionMap;
stringFunctionMap.add("string1", &String1Action);*/
insert(t,10);
find(t,0);
//Delete(t,10);
}
so the question what is ideal way of calling Insert, Delete and Find by splitting the line? i need to take care the performance. One approach i found out is to create enum with key and value pair and having function pointer. so depending on the key value ("I","D","F") the appropriate function will be called with it's respective value. Can you please suggest me/correct my approach and guide me on this code. Appreciate your time. Thanks