Re: Storing values in dictionary with their address as the key
Re: Storing values in dictionary with their address as the key
- Subject: Re: Storing values in dictionary with their address as the key
- From: Andy Lee <email@hidden>
- Date: Mon, 28 Jul 2008 16:05:45 -0400
On Jul 28, 2008, at 3:40 PM, Charles Srstka wrote:
On Jul 28, 2008, at 2:29 PM, Jonathan Hess wrote:
A good reason would be that you care about identity equality and
not value equality. You care that the key is the exact same
instance, not that it is an equivalent instance. (== vs isEqual:)
Another reason would be that the keys might not implement
NSCopying, which NSDictionary requires.
But couldn't you just do that with an NSArray instead of an
NSDictionary, using -indexOfObjectIdenticalTo: and such?
Yes, but then lookups would be O(n) instead of O(1). But only the OP
can tell if that would be premature optimization.
Probably the simplest solution would be if there was something built-
in like Java's IdentitySet.
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden