My question seems similar to vector of objects vs vector of pointers to objects but reading it hasn't answered my question.
I'll avoid the details for why my program is structured the way it is, because that isn't particularly relevant.
- I have three vectors of pointers to 18 streampos vectors of unknown length (depending on input) (lets refer to these streampos vectors collectively as A's(A1,A2...A18), and the three vectors containing A's lets call B's(B1,B2,and B3)
- For reasons explained below, I have a vector of pointers to B's, lets refer to this vector as C.
to reiterate, i have a vector(C) containing three pointers each, to vectors(B) containing 18 pointers each, to vectors(A) of streampos.
- I have a function nuc() which main() calls 120 times.
- nuc() is recursive and calls itself ~33000 times (2^15).
- a function check() is called by nuc() once every time nuc() is called (i could therefore move check() into nuc() without changing the functionality much, just making the code a bit messier). Check() is the function which interacts with my A's.
Each time main() calls nuc(), it passes to nuc() a specific B (because there are three B's containing 18 A's each). Every time nuc() calls check(), it passes to it the relevant specific A (e.g. A16). Check() then push_back()s a value into the relevant A.
It's come to my attention that i need to generate an int vector for every streampos vector to carry relevant information, but it seems odd to instantiate literally 108 vectors. I've been thinking of instead instantiating each B as a vector of 18 vectors.
Would i have any issues push_back()ing values into its subvectors? Is there any reason i should choose a vector of vectors over a vector of vector pointers beside the visual silliness of instantiating 108 vectors? what benefits does a vector of vectors have over the former, besides the one i mentioned?
I apologize if the question is pedantic, this is my first C++ program and I looked at about 7 pages on the topic but struggled to find an answer.
here's a pseudocode example:
fstream file1;
vector<streampos> A0_0...A0_18, A1_0...A1_18,...
vector<vector<streampos>*> B0 = {&A0_0...&A0_18},
B1 = {&A1_0...&A1_18}...
vector<vector<vector<streampos>*>*> C = {&B0, &B1, &B2}
main()
string line;
while(getline(file1,line))
int B_determiner = line[-1] //suppose 0
vector<vector<streampos>*> B = C[B_determiner] //suppose B0
nuc(line, B)
nuc(string line,vector<vector<streampos>*> B) // B = B0
string new_line = line.do stuff to line...
A_determiner = new_line[0]
A = B[A_determiner] //suppose A0, therefore A0_0
check(new_line, A)
check(string new_line, vector<streampos> A) //A = A0_0
streampos value = derive a streampos from new_line...
A.pushback(value)