vector<vector<largeObject>> vs. vector<vector<largeObject>*> in c++
Posted
by
Leif Andersen
on Stack Overflow
See other posts from Stack Overflow
or by Leif Andersen
Published on 2011-01-18T01:52:56Z
Indexed on
2011/01/18
2:53 UTC
Read the original article
Hit count: 283
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
© Stack Overflow or respective owner