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: Jeffrey Oleander <email@hidden>
- Date: Fri, 21 Aug 2009 09:39:31 -0700 (PDT)
> On Fri, 2009/08/21, Quincey Morris <email@hidden> wrote:
> From: Quincey Morris <email@hidden>
> Subject: Re: When do I need to override hash?
> To: "cocoa-dev" <email@hidden>
> Date: Friday, 2009 August 21, 00:48
>> On 2009 Aug 20, at 22:05, Jeff Laing wrote:
>> 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..
>>>>> "If a mutable object is added to a collection
>>>>> that uses hash values to determine the
>>>>> object’s position in the collection, the
>>>>> value returned by the hash method of the
>>>>> object must not change while the object
>>>>> is in the collection."
The impression I get from all this is that
* if you do want to change how you hash,
you should pull objects out of the collections
with the old hash and then add them back in
using the new hash.
* be careful when choosing a hash scheme; it
has to be fast and it has to produce keys
that minimize collisions and yet come out
the same when you want it to come out the
same.
_______________________________________________
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