How are 2D static arrays allocated?
Jarrett Billingsley
jarrett.billingsley at gmail.com
Mon Nov 3 22:34:26 PST 2008
On Mon, Nov 3, 2008 at 11:30 PM, Jesse Phillips
<jessekphillips at gmail.com> wrote:
> In C allocating a static 2D array gives a continues chunk of memory. Java
> creates an array that points to more arrays. Just wondering how D handles
> this.
If it's a 2D fixed-size array, like:
int[5][6] x;
Then it is allocated as a single chunk of memory, and when you index
it, it calculates the offset into that block of memory.
But 2D dynamic arrays:
int[][] y;
Are handled like in Java - an array of arrays. When you index it, it
indexes the first array, then indexes the second array.
More information about the Digitalmars-d-learn
mailing list