posted 18 years ago
Ok so i have a situation where the array i need to create could be a maximum of 2^n size, but rarely does that happen. Usually it is around a third of that. So i guess my question is:Should i still just make an array of size 2^n, and intialize all elements(which i must do ) or should i just make it bigger each time i have to add something to it, since the number of elements rarely reaches the true size of it. i would have to do an array copy to copy the old array thus far into the new one, and i dont really know if i should do this or just make an array with an intial size of the mximum capacity at te beginning.
I know that your probably going to say use a vector, but my array is two dimensional, and the code im working with was someone elses which requires a 2d array and i dont want to go change all his work.
so based on that, which one is faster:intialze to max size...or to array copy and make a new one each time a new element is added?
National Research Council<br />Internet Logic Department