• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: When do I need to override hash?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: When do I need to override hash?
      • From: Seth Willits <email@hidden>
References: 
 >When do I need to override hash? (From: Gideon King <email@hidden>)
 >Re: When do I need to override hash? (From: Nathan Vander Wilt <email@hidden>)
 >Re: When do I need to override hash? (From: Gideon King <email@hidden>)

  • Prev by Date: Re: When do I need to override hash?
  • Next by Date: Re: FYI - new debug & profile libraries are out: Installer Refuses
  • Previous by thread: Re: When do I need to override hash?
  • Next by thread: Re: When do I need to override hash?
  • Index(es):
    • Date
    • Thread