I have two vectors of same length. One of them holds vectors of double :
std::vector<std::vector<double>> A;
and the second one holds doubles
std::vector<double> B;
By "the same length" I mean that A contains as many vectors of double as B contains double. I would like to iterate through both of them with a single iterator at the same time. I have a feeling I need to create a class to do that. Something like
std::vector<vector<double>>::iterator iter = A.begin();
for (A= iter.begin(); iter != A.end(); iter++)
{
(*iter).A // I access an element of A std::vector<double>
(*iter).B // I access an element of B (double)
}
I checked a similar question and this one is pretty close to what I want to do: C++ iterating over 2 vectors using for loop
but in my case the iterators have two different types, respectively std::vector<vector<double>>::iterator and vector<double>::iterator, so the solution of this question does not work, but I guess it is pretty close.
How can I do it? What would be the best way?