To strictly answer your question, Joachim Pileborg's Answer is the way to go:
std::list<std::list<double> >::iterator it = list.begin(); std::advance(it, 3); std::list<double>::iterator it2 = (*it).begin(); std::advance(it2, 3); double d = *it2;
Now, from your question and further comments, it is not clear whether you always add items to the end of lists or whether you can add them anywhere. If you always add at the end, vector<double> will work better. A vector<T> does not need to be copied every time its size increases; only when its capacity increases, which is completely different.
In addition to this, using reserve() as mentioned earlier will help a lot in redistribution. You do not need to reserve the combined size of all vectors, but only for each individual vector. So:
std::vector<std::vector<double> > v; v.reserve(512);
And you will also reserve for each vector<double> inside v . It's all.
Please note that your list of lists will take up much more space. For each double in the internal list, it will have to select at least two additional pointers, as well as two additional pointers for each list in the global least. This means that the total memory occupied by your container will be approximately three times larger than that of the vector. And all this distribution and management also requires additional lead time.
source share