Growing multidimensional dynamic arrays

KillerSponge killersponge at gmail.com
Mon Oct 8 06:12:40 PDT 2012


Hi all,

This seems like something that should be possible: how do I grow 
multidimensional arrays?

I want something like this:

struct X{ ... };
X*[][] listOfLists;
foreach ( x ; otherListOfX ) {
    if ( newListForArbitraryReason ) {
       listOfLists ~= new X*[];
    }

    listOfLists[$] ~= x;
}

Now, this doesn't compile, because I _have_ to give a size to new 
X*[](arbitrary_number), and the listOfLists[$] ~= x; line never 
works (hangs at runtime).

So, how would I go about doing this? My apologies if this is 
something really obvious.


More information about the Digitalmars-d-learn mailing list