Re: multidimensional arrays
Re: multidimensional arrays
- Subject: Re: multidimensional arrays
- From: Thomas Davie <email@hidden>
- Date: Mon, 14 Mar 2005 12:55:43 +0000
On Mar 14, 2005, at 12:39 PM, j o a r wrote:
On 2005-03-14, at 13.34, Andy Armstrong wrote:
Actually quite a few languages implement them as a single array of
size rows * cols and do the necessary arithmetic on the index to hit
the right slot. That's an approach that would work with NSArrays too.
In general (and in psuedocode)
int x[cols, rows] ==> int x[cols * rows]
x[c, r] = n ==> x[c * rows + r] = n
I'd assume, without having given it too much thought, that a
category could be added to NS(Mutable)Array to do the same.
Wouldn't that require that NSArray supported that some indexes are
not populated with data (which it doesn't)?
Of course, you could pre-populate your array with dummy data ([NSNull
null] or similar), in which case it would probably work like you
suggest.
Not if you impose a similar constraint that Multi-dimensional arrays
must have data in all of their slots (just like the current
uni-dimensional arrays). I've always found it a bit strange that cocoa
imposes this condition on arrays, they are after all meant to be
arrays, not lists.
Bob
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden