digitalmars.D - Array and Memory
- Pac <Pac_member pathlink.com> Jul 22 2004
- Ben Hinkle <bhinkle4 juno.com> Jul 22 2004
- Derek Parnell <derek psych.ward> Jul 22 2004
- J Anderson <REMOVEanderson badmama.com.au> Jul 23 2004
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Jul 23 2004
- J Anderson <REMOVEanderson badmama.com.au> Jul 23 2004
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Jul 24 2004
- Norbert Nemec <Norbert.Nemec gmx.de> Jul 26 2004
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:Hello, I was wondering, how much memory size is needed for a multidimensional array like : int[12][12] tab;
int.sizeof*12*12
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 AM
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 ?
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: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.
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/
Jul 23 2004
J Anderson wrote:Jarrett Billingsley wrote: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.
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.
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.
Jul 26 2004









Derek Parnell <derek psych.ward> 