Vector of vectors

Hi!

i have a question. I have a lot of data in a 2d array and want to know the most efficient way to save it. It mainly has numbers of long long. Is vector of vectors a good idea where one vector holds the info of a row and the other vector the starting address of each row? If there be an better way please help!!

Thanks!
Tacy :)
Yes, a vector of vectors.

Ideally, not
one vector holds the info of a row and the other vector the starting address of each row?

but

std::vector< std::vector< long long > > ;

one vector holds the the vectors for each row
and the vector for each row holds the long long values in that row
1
2
std::vector<long long> data;
size_t cols;
where m_{jk} is mapped to m_{j*cols+k}
Since 80% of my matrix is full of 0s i think using a map nested in a vector would be a better idea. However I am having trouble with syntax coz I defined it like: std::vector< std::map<std::string,long long> > data; but now how do I add an element or value???
Last edited on
Topic archived. No new replies allowed.