Obviously it will vary depending on the compiler you use, but I’m curious as to the performance issues when doing vector<vector<largeObject>> vs. vector<vector<largeObject>*>, especially in c++. In specific:
let’s say that you have the outer vector full, and you want to start inserting elements into first inner vector. How will that be stored in memory if the outer vector is just storing pointers, as apposed to storing the whole inner vector. Will the whole outer vector have to be moved to gain more space, or will the inner vector be moved (assuming that space wasn’t pre-allocated), causing problems with the outer vector?
Thank you
Vector is internally a pointer so pointer of vector is sort of overkill.
Vector of pointers or smart pointers is usually used when polymorphic contents are needed.
In C++03 it may be expensive to insert more vectors or (erase existing ones) of your master vector but C++0x resolves even that issue with its move semantics.
It is better to switch to more suitable containers later after profiling with real data instead of trying to make it initially extremely dynamic.