I am reading a text file containing values like below (file may be 16.000 to 100.000 lines)
Each line is read and parsed with a parser. The values are pushed into a vector as "A-B" pairs. But at the same time, I also need to count the occurrence of any value in first column
To do so;
1 ) I can create two vectors, one to hold "A-B" pairs and the other to hold a STL Map container (key to be "A" and value is "3" for example). But, each time I read a new line, I have to trace the second vector, find relevant key and increase the related value by 1 and update the map vector. this is does not seem so efficient
2 ) I can read file twice. At first round, I can create the map vector (that holds the name of element and number of its occurrence). In second tour, I create the "A-B" pairs. But reading file twice also seems a little bit "ad performance solution"
3 ) I can use some sql engine, like Sqlite. Like reading file once and fill my sql table, and do the rest of the job with SQL. I really do not have an idea about the performance of this solution.
Any other options are welcome.
Thanks in advance....