I need to create a sort of 2D array in which each one of the secondary arrays are of different length. I have a 1D array of known length (which defines the number of arrays to be formed) with each element having a number that denotes the length of the secondary array in that position.
Each one of the arrays are fairly large so i don’t want to create a one-size-fits-all “fake” 2D heap array to cover everything.
How would i go about doing this? Any 2D array I have made before are always rectangular.
I’m trying to do this so that i can create some code to dynamically generate threads to split up some workload.
Thanks,
-Faken
You can do something like following :
Do not forget to deallocate properly after you are done with using
array.EDIT :
You can put secondary pointer initialization in the loop in the following way :
PS : I personally prefer to use Boost.MultiArray when I need multidimensional arrays. You might also want to have a look at it.