Is there an STL container similar to a list in that elements of lists are not stored contiguously? The size of this container can be up to 1000x1000 elements with each element being a vector containing 36 doubles. This would be a large chunk to store together (like ~200 megabytes). Is there a variant that instead stores pointers to its contents as a separate vector so it would allow for random access. Is there an STL container class for this that already exists or should I just store the pointers manually?
The container I need is actually a constant size so I think implementing it myself wouldnt be too difficult, but I was wondering if an STL container already exists for this. I'd like to avoid a vector because the list is large and the contents will be of medium size. If the vectors in the container don't need to reside next to each other then wouldn't it be better to separate them in a list to prevent running out of memory from fragmentation?
std::array<std::unique_ptr<T>, length>? - Mooing Duckstd::vector<T>orstd::array<T, n>are you concerned about? - ecatmurvectororarray! - ecatmurlistin what respect? Fast insertion/deletion at an iterator? Elements never relocate? If all you need is a sequence, then the standard sequences (aside fromarray) arevector,dequeandlist. As far as contiguity is concerned,vectoris contiguous,dequeneed not be contiguous but it has random access and for ops like insert/remove in the middle it need not be any faster than if it was,listis non-contiguous and guarantees the benefits (and drawbacks) of non-contiguity. - Steve Jessoparrayfor the fixed-size rows, so I wanted to cover that case. But if it does hold avectorthen agreed. It won't get really big until you're starting to run out of total memory anyway, so it's not going to make a difference of more than (say) a factor of 2-ish in max size that works. - Steve Jessop