• 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
Fwd: multidimensional arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: multidimensional arrays


  • Subject: Fwd: multidimensional arrays
  • From: Thomas Davie <email@hidden>
  • Date: Mon, 14 Mar 2005 13:09:23 +0000

*remembers to send it to the list*

Begin forwarded message:

From: Thomas Davie <email@hidden>

Date: March 14, 2005 12:55:43 PM BST

To: j o a r <email@hidden>

Cc: Andy Armstrong <email@hidden>, Cocoa-Dev Development <email@hidden>

Subject: Re: multidimensional arrays



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

References: 
 >Re: multidimensional arrays (From: Thomas Davie <email@hidden>)

  • Prev by Date: Re: multidimensional arrays
  • Next by Date: Re: how to show other application in front of others?
  • Previous by thread: Re: multidimensional arrays
  • Next by thread: Re: multidimensional arrays
  • Index(es):
    • Date
    • Thread