View Full Version : extracting QVectors from a multidimensional QVEctor array

22nd February 2012, 09:24

If I have an array that is defined by a QVector<Qvector<QVector<double> > > and lets say its dimensions are [7, 10000, 5] is there any easy way for me to extract the data from a given dimension without having to run for loops?
e.g. I want to extract the first entry of the last dimension so I have an new array that is size [7, 10000], or lets say I want to extract the 10th entry of the second dimension so I have a new [7,5] array etc etc

In a programming language I was using before (an interpreted language) I could for example request the first case I used above by saying new_array = old_array[*,*,0] where the * tells the program to get all of the entries in those dimensions, or in the second case new_array = old_array[*,9,*]

My Qt code I have at the moment works and I guess it is fast enough for me but if I can avoid another set of for loops I would like to


or pending a lack of any method etc, a recommended strategy would be cool as well

23rd February 2012, 00:58
Ok so assuming it isn't a question that's going to be answered I guess the alternative is can someone show me how to use the foreach statement with multidimensional QVectors?


23rd February 2012, 08:45
QVector<QVector<QVector<int>>> vvv;

foreach (QVector<QVector<int>> vv, vvv)
foreach (QVector<int> v, vv)
foreach (int i, v)
std::cout << i;