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: "Adam R. Maxwell" <email@hidden>
- Date: Wed, 19 Aug 2009 18:42:14 -0700
On Aug 19, 2009, at 6:17 PM, Gideon King wrote:
In other cases where I make few changes but do lots of comparisons,
I might use the string hash idea and cache the return value in the
object, triggering an update whenever the relevant data changes.
This would be easy for me because the objects in question can
archive themselves to XML and I could use the XML string.
Note that you must not change the hash of an object while it is in a
hashing collection; this causes bugs that can be really hard to track
down (I learned the hard way). See this article, specifically the
note on "The mutable pitfall."
http://www.mulle-kybernetik.com/artikel/Optimization/opti-7.html
Some of the comments on Apple's implementation are likely dated, but
it's still good background reading.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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