RE: When do I need to override hash?
RE: When do I need to override hash?
- Subject: RE: When do I need to override hash?
- From: Jeff Laing <email@hidden>
- Date: Fri, 21 Aug 2009 05:05:40 +0000
- Acceptlanguage: en-US
- Thread-topic: When do I need to override hash?
> Separately, collections may (and presumably sometimes do) use *object*
> hash values to distribute objects in memory. (Obviously, NSSet does,
> and for all we know NSDictionary does too, to distribute object values
> that stored under the same key hash value -- though it would be an
> implementation detail.)
Without wanting to keep the thread going forever, can I just ask why we would presume this?
In fact, if I were implementing NSDictionary I'd assume the reverse, that I was not allowed to assume that an objects hash would not change.
Is there some documentation on this restriction on the types of objects that can be put into an NSDictionary?
I can see the NSSet dictates that objects must implement hash and isEqual: but NSDictionary only says that "internally a dictionary uses a hash table" - there are limits on the keys, which must conform to NSCopying,etc but I can't see anything about the values.
Surely using an NSSet as bucket storage, for all objects whose keys hash to the same value, would add additional restrictions to NSDictionary that should be documented?
_______________________________________________
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