Re: multidimensional arrays
Re: multidimensional arrays
- Subject: Re: multidimensional arrays
- From: j o a r <email@hidden>
- Date: Mon, 14 Mar 2005 13:39:52 +0100
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.
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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