Vector of Vectors is not sufficient


My program enters the size the of the vector from the user and then creates a vector of vectors (lets say SIZE1). In addition the user enters the number of vector of vectors he needs (lets say SIZE2) as follows:

class Vectors
// member functions goes here
vector<vector<int>> vectors;
vector<int>::iterator it;

void main()
A = new Vectors*[SIZE2];
for (int i=0; i<SIZE2; i++)
A[i] = new Vectors[SIZE1];

Now the size of A is fixed (SIZE2) though out the run. Also the size of the outer vector of Vectors is fixed (SIZE1) through out the run... But the size of the inner vector of Vectors is unknown and it grows during the run...

My program is working fine with small number of SIZE1 and few insertions to the inner vector of Vectors... But with many insertions to the inner vector of Vectors the program stops the run and does not give any results...

My questions are:
1. Is there any way I can set the size of the inner vector to a very high number? (I have a 32 RAM)
2. Do I have to use lists or any other thing other than vectors? I would prefer to find a way to fix my vectors other than changing to lists or any other thing because my program is huge and it will take me more than a month to change the code...

Best regards,
Vectors are dynamically allocated data structures, meaning that they can grow and expand depending upon the input of a user.

For your second question, used a fixed-allocation data structure such as an array which you can declare the size of.

Hope that helps!

Thank you for your reply...

Actually, I cannot use arrays because their maximum size is small for me... That's why I thought vectors are better...

My program works fine with a small number of insertions to my vector (vector of vectors) but the problem occurs when I have a huge number of insertions... The program stops execution without giving me a reason... In my opinion, I guess vectors have a maximum size that they cannot grow beyond and that's why my program stops working...

Let me change the questions, maybe it's better to ask:
1. What is the maximum size that a vector cannot grow beyond?
2. Is their anything I can do with the setting of my visual stdio (im using version 2012) that I can do to increase the size of my vectors to allow some thing like 1000000 row?

Thank you...

Best regards,
I found the maximum size that a vector cannot grow beyond... its 2G on my computer... when it reaches 2G I get a runtime error...

However, with my program when I have a huge number of insertions to the vector, the program just stops execution without giving me a run time error which means that the vector did not reach the limit yet...

Anyhow, I found my problem.. I had a reallocation exception, I found it while debugging the program... It happens when the vector gets very big and tries to be reallocated somewhere else in the memory...
Last edited on
Topic archived. No new replies allowed.