• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: multidimensional arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: multidimensional arrays
      • From: Andy Armstrong <email@hidden>
    • Re: multidimensional arrays
      • From: Thomas Davie <email@hidden>
References: 
 >multidimensional arrays (From: Daniel Child <email@hidden>)
 >Re: multidimensional arrays (From: Thomas Davie <email@hidden>)
 >Re: multidimensional arrays (From: Andy Armstrong <email@hidden>)

  • Prev by Date: Re: multidimensional arrays
  • Next by Date: Re: multidimensional arrays
  • Previous by thread: Re: multidimensional arrays
  • Next by thread: Re: multidimensional arrays
  • Index(es):
    • Date
    • Thread