data containers

Moritz mpipahl at gspgmbh.com
Fri Jul 4 15:49:58 PDT 2008


Thank you torhu, I finally managed to get something into this array! :-)

But I still dont understand if and how I can add a new ScreenElement 
array to the layer map *without* setting its size in advance(because I 
want to remain as generic as possible).

My original idea was to have a create_layer() function, which creates a 
new layer by adding an empty array to the layer map, so I can keep 
creating as many layers as I want to.

And another question: Can I modify the size of an array after I set it 
manually?


> You need to add the layers before you can add ScreenElements to them. Do 
> you have a fixed number of layers? Then what you suggested will work:
> 
> ScreenElement[][] layer_map = new ScreenElement[][5];
> 
> If you are used to working with pointers, dynamic arrays are just that, 
> except that they store the length of what the pointer points to too. 
> It's only that some operations on them actually allocate memory.  "~", 
> "~=", and explicitly setting .length allocates.  Indexing does not 
> allocate.


More information about the Digitalmars-d-learn mailing list