Hi Friends,
I have to store large amount of data and retrieve the same data then write into file in C++.
Currently I am using vector to store and retrieve. But vector is taking more time to store and retrieve the element. Is any other best data structure to store and retrieve large amount of data in unordered way?
Please suggest me the best solution to reduce the time.
Example code:
Thanks,
Jothi
I have to store large amount of data and retrieve the same data then write into file in C++.
Currently I am using vector to store and retrieve. But vector is taking more time to store and retrieve the element. Is any other best data structure to store and retrieve large amount of data in unordered way?
Please suggest me the best solution to reduce the time.
Example code:
Code:
int I1 = 700,I2 = 32, I3 = 16; //declare and resize the vector size vector< vector < vector < vector<DOUBLE> > > > vPARAM; vPARAM.resize(I1, vector< vector < vector<DOUBLE> > > (I2, vector< vector<DOUBLE> > (I3, vector<DOUBLE> (0)))); //Insert //In the Loop //The final index "value" it will go unlimited //I1,I2,I3 also, i will store randomly... //For eg,First time i will store 100the element,then 50th.... vPARAM.at(I1).at(I2).at(I3).push_back(value); //Retrieve //In the Loop for(lines =0; lines < vecPARAMETER.size();lines++) iValue = vecPARAMETER[I1][I2][I3][lines]; fwrite(&iValue,8,1,fp);
Thanks,
Jothi
Comment