Hi...
My input file is as follows :-
A<-B<-C<-D
A<-C<-E<-F<-P
.......
.....
What i want is to first store the given input as follows :-
{{{A,B},{B,C},{C,D}},{{A,C},{C,E},{E,F},{F,P}}}
and then make a check if the pair is present in particular subset of a set.
For e.g if the user can give index 0 and pair {B,C} we need to search the first index value i.e {{A,B},{B,C},{C,D}} and return true or false based on its presence.
Till now my code is as follows which reads each line of the given file and retrieve the element values by using tokenizer of boost lib. How to proceed further i tried using vector and map for storing in the above format but it is not helping me much.
In case of any doubts on the problem statement kindly let me know that
Kindly help
void main(int argc,char* argv[])
std::ifstream datafile(argv[1]);
if (!datafile)
{
std::cerr << "No " << datafile << " file found" << std::endl;
exit(1);
}
int line_no=0;
string first_element;
string second_element;
int count=0;
char_delimiters_separator < char >sep(false, "", "<-");
for (std::string line; std::getline(datafile, line);)
{
tokenizer <> line_toks(line, sep);
tokenizer <>::iterator iter = line_toks.begin();
line_no++;
if (line_toks.begin() == line_toks.end())
continue;
for(;iter!=line_toks.end();iter++)
{
if(count==0)
{
first_element=*iter;
count++;
continue;
}
else
{
second_element=*iter;
}
first_element=second_element;
/*******
Now i got the values of first element and second element correctly how to store it and retrieve in the above mentioned structure
***********/
count++;
}//End-for --i
}//End-for getline