I have a std::map<string, int>
and std::vector<vector<double>>
. I have to iterate both the container at the same time doing this way. And i would like to update the value of 2-D std::vector
.
map<string,int> portfolioCategories = optimizationPortfolioCategories();
vector<vector<double>> coVarianceMatrix(numberOfCategory,vector<double>(numberOfCategory));
auto map_itr = portfolioCategories.begin();
auto vec_itr = coVarianceMatrix.begin();
for(; map_itr != portfolioCategories.end() && vec_itr != coVarianceMatrix.end(); map_itr++, vec_itr++) {
for(const auto& it: (*vec_itr))
it = coVariance(monthlyReturnFundCategory[index],monthlyReturnFundCategory[count]);
}
How can I iterate over both the container at the same time, so that i can update the value of 2D vector.