digitalmars.D - Array and Memory
- Pac (9/9) Jul 22 2004 Hello,
- Ben Hinkle (3/19) Jul 22 2004 linear. see http://www.digitalmars.com/d/arrays.html "Rectangular arrays...
- Derek Parnell (15/26) Jul 22 2004 Proof:
- J Anderson (7/19) Jul 23 2004 Static arrays are rectangular (linear). Dynamic arrays are an array of
- Jarrett Billingsley (5/7) Jul 23 2004 hmm.. that would be somewhat inefficient if you were to add a column or
- J Anderson (11/21) Jul 23 2004 I think you miss-understood me. "as well" means "in addition" in my
- Jarrett Billingsley (1/1) Jul 24 2004 ah, i didn't see the "as well".
- Norbert Nemec (9/36) Jul 26 2004 Note that my proposal in that direction is still in the pipe:
Hello, I was wondering, how much memory size is needed for a multidimensional array like : int[12][12] tab; Are multidimensional arrays in D linearly implemented or is like in Java a first array containing references to other arrays ? If there is no linar implementation, do you intend to provide one ? Best regards Pac
Jul 22 2004
Pac wrote:Hello, I was wondering, how much memory size is needed for a multidimensional array like : int[12][12] tab;int.sizeof*12*12Are multidimensional arrays in D linearly implemented or is like in Java a first array containing references to other arrays ?linear. see http://www.digitalmars.com/d/arrays.html "Rectangular arrays"If there is no linar implementation, do you intend to provide one ? Best regards Pac
Jul 22 2004
On Thu, 22 Jul 2004 20:04:25 -0400, Ben Hinkle wrote:Pac wrote:Proof: <code> void main() { int[12][12] tab; printf("int[12][12] tab;\n"); printf("int.sizeof*12*12; is %d\n", int.sizeof*12*12); printf(" tab.sizeof; is %d\n", tab.sizeof); } </code> -- Derek Melbourne, Australia 23/Jul/04 10:11:40 AMHello, I was wondering, how much memory size is needed for a multidimensional array like : int[12][12] tab;int.sizeof*12*12
Jul 22 2004
Pac wrote:Hello, I was wondering, how much memory size is needed for a multidimensional array like : int[12][12] tab;tab.sizeofAre multidimensional arrays in D linearly implemented or is like in Java a first array containing references to other arrays ?Static arrays are rectangular (linear). Dynamic arrays are an array of references. Personally I would like a rectangular arrays for dynamic arrays as well.If there is no linar implementation, do you intend to provide one ? Best regards Pac-- -Anderson: http://badmama.com.au/~anderson/
Jul 23 2004
Personally I would like a rectangular arrays for dynamic arrays as well.hmm.. that would be somewhat inefficient if you were to add a column or something. if you added a row, it would only have to allocate room for one more roaw at the end. but if you added a column, it would have to allocate enough room for a column, then copy each row over enough to make room for the column. not fun.
Jul 23 2004
Jarrett Billingsley wrote:I think you miss-understood me. "as well" means "in addition" in my comment. All depends what you use it for. Certainly if its a vertex buffer then its more efficient to use a rectangular array. This is how I see it: int [][] array; //dynamic array of arrays int [,] array; //dynamic rectangular array. int [width, ] array; //rectangular array with a fixed width Note that rectangular arrays are possible with D, just not in a neat way. -- -Anderson: http://badmama.com.au/~anderson/Personally I would like a rectangular arrays for dynamic arrays as well.hmm.. that would be somewhat inefficient if you were to add a column or something. if you added a row, it would only have to allocate room for one more roaw at the end. but if you added a column, it would have to allocate enough room for a column, then copy each row over enough to make room for the column. not fun.
Jul 23 2004
J Anderson wrote:Jarrett Billingsley wrote:Note that my proposal in that direction is still in the pipe: http://homepages.uni-regensburg.de/~nen10015/documents/D-multidimarray.html Walter seemed pretty much in favor of the idea in general, but made it clear that it will be a past-1.0 issue. I will continue refining the proposal as soon as I find the time. (Hopefully in late summer.) There is a number of ideas that came up since the last published version. Especially, the whole issue of array expressions needs to be worked in.I think you miss-understood me. "as well" means "in addition" in my comment. All depends what you use it for. Certainly if its a vertex buffer then its more efficient to use a rectangular array. This is how I see it: int [][] array; //dynamic array of arrays int [,] array; //dynamic rectangular array. int [width, ] array; //rectangular array with a fixed width Note that rectangular arrays are possible with D, just not in a neat way.Personally I would like a rectangular arrays for dynamic arrays as well.hmm.. that would be somewhat inefficient if you were to add a column or something. if you added a row, it would only have to allocate room for one more roaw at the end. but if you added a column, it would have to allocate enough room for a column, then copy each row over enough to make room for the column. not fun.
Jul 26 2004