• 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: Implementing isEqual: and hash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing isEqual: and hash


  • Subject: Re: Implementing isEqual: and hash
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Sat, 23 Aug 2008 17:52:21 -0700


On Aug 23, 2008, at 5:20 PM, Peter Duniho wrote:

Date: Sat, 23 Aug 2008 12:05:44 -0700
From: "Adam R. Maxwell" <email@hidden>



[...]

Note the redundant multiply and add in the first line. Writing the code that way makes it easy to add/remove members if for some reason the data structure should change in the future. But it would be just as correct to simply initialize ret to the first hash value, of course.

Thanks for the example...I need to find time to do some profiling with this.


Presumably that
depends on the hash table implementation as well.

Well, if your hash values collide, they collide regardless of the hash table. As long as you've got a well-distributed hash function, any collisions generated by the hash table implementation should be well-distributed as well.

My understanding was that the table might not use all bits of the hash value, so even differing hash values could be placed in the same bucket; that may be a misinterpretation of [1]. I find CFSet/CFBag/ CFDictionary to be one of the more confusing implementations in CF-Lite.


thanks,
Adam

[1] http://www.mulle-kybernetik.com/artikel/Optimization/opti-7.html

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

References: 
 >Re: Implementing isEqual: and hash (From: Peter Duniho <email@hidden>)

  • Prev by Date: specify a NSPredicate for jpeg file names?
  • Next by Date: Re: textfield not updating with bindings - Whats wrong?
  • Previous by thread: Re: Implementing isEqual: and hash
  • Next by thread: Re: Implementing isEqual: and hash
  • Index(es):
    • Date
    • Thread