At 9:45 PM +0100 7/2/02, Nicholas Clark wrote:
>On Thu, Jun 27, 2002 at 05:42:10PM +0200, Josef Höök wrote:
>>  I've been thinking abit on howto implement multidimensional arrays and
>>  i found that its quite tricky :). I'm currently thinking of having
>>  a structure that contains a data pointer and its location in every
>>  dimension something like this:
>>
>>  typedef struct CELL {
>>    int dim[100];
>>    int *data;
>>  } cell;
>>
>>  cell *a = (cell *)malloc((unsigned) (2)*sizeof(cell *));
>>
>>  // A cell with location in a 3 dim space a(2;4;6)
>>   a->dim[0] = 2;
>>   a->dim[1] = 4;
>>   a->dim[2] = 6;
>>   a->data = data1;
>
>I wouldn't like to do it quite like that, as you've got a hard coded constant
>in there. Why should we prevent crazy people making arrays with dimensions
>greater than 100, and why should we have most people who only want a 2D array
>having to carry 98 unused ints around as baggage.

Nick makes a number of good points here (including ones I've
chopped). It's not unreasonable to have matrices of fixed
dimensionality, at least to start, even if the size in each dimension
is variable. Which is to say, you have to know that it's a 3D matrix,
even if you don't know how far it goes in each of the 3 dimensions.

>On Tue, Jul 02, 2002 at 03:24:03PM -0500, Dan Sugalski wrote:
>  > One of the nice things about PMCs is that all the implementation
>>  details are just that--details. They hide on the other side of the
>>  wall marked "Do Not Peek Past This Point". :)
>
>or "Here Be Dragons"

Heh. Good point, but at least we have some pretty big Dragon fences
in place. ;-P

>  > I really need a room with a wraparound whiteboard...
>
>Does it really matter what shape the room is, once one has had the caps off
>the marker pens for long enough? :-)

At that point I need a wraparound sweater, which is a different
matter entirely.
--
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                       teddy bears get drunk

Reply via email to