Re: Multidimensiaon Arrays in Cocoa
Re: Multidimensiaon Arrays in Cocoa
- Subject: Re: Multidimensiaon Arrays in Cocoa
- From: "John C. Randolph" <email@hidden>
- Date: Sun, 23 Sep 2001 08:58:56 -0700
On Sunday, September 23, 2001, at 06:26 AM, Ondra Cada wrote:
John,
John C. Randolph (JCR) wrote at Sun, 23 Sep 2001 05:52:41 -0700:
JCR> One trick that just occurred to me for storage of values of a
sparse
JCR> array of any number of dimensions, is to keep the values in an
JCR> NSDictionary, where the key is the contatenation of the
coordinates.
Actually, it is much cleaner to use an NSArray. Ie., instead of
// a contains the indices
[d setObject:value forKey:[a componentsJoinedByString:@":"]]
you would use directly
[d setObject:value forKey:a]
I don't think that would work, unless NSDictionary actually uses the
value of [a description] for the key. I just tried making a few arrays
in GDB, and all arrays with the same number of items returned the same
value from -hash, no matter what the contents were.
-jcr
"I fear all we have done is to awaken a sleeping giant and fill him with
a terrible resolve." -Admiral Isoroku Yamamoto, Dec 7, 1941.