I have a code which only retrieves all the elements in a vector. I want to retrieve only the vector elements for a specified range which would be given to the function. I have tried iterator incrementing but I am unable to check the end of the range for which I want the vector elements. Code:
void calculate(int start, int end)
{
//Vector dupViewResults is already populated with another function
//The definition of dupViewresults is vector<vector<string>> dupViewResults
vector< vector<string> >::iterator row;
for (row = dupViewResults.begin(); row != dupViewResults.end(); ++row)
{
std::advance(row, start); //Setting the iterator to the starting element.
std::string filedata = readFileDataInStr(row->at(0));
int x = boost::lexical_cast<int>( row->at(1) );
long long int fileCRC32 = MurmurHash(filedata.c_str(), x, 0);
std::string strCRC32 = std::to_string(fileCRC32);
std::string query = "update duplicatesview set CRC32='" + strCRC32 + "' where Filepath='" + row->at(0) + "'";
char* charQuery = &query[0];
db.fireSQLQuery(charQuery, results);
}
}
In the above code, I am not sure how to check the end position and then break. Thanks in advance for your help.
why not use this -