• 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: 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

  • Follow-Ups:
    • Re: When do I need to override hash?
      • From: Quincey Morris <email@hidden>
References: 
 >When do I need to override hash? (From: Gideon King <email@hidden>)
 >Re: When do I need to override hash? (From: Seth Willits <email@hidden>)
 >Re: When do I need to override hash? (From: David Duncan <email@hidden>)
 >Re: When do I need to override hash? (From: Clark Cox <email@hidden>)
 >Re: When do I need to override hash? (From: Bryan Henry <email@hidden>)
 >Re: When do I need to override hash? (From: Clark Cox <email@hidden>)
 >Re: When do I need to override hash? (From: Kyle Sluder <email@hidden>)
 >Re: When do I need to override hash? (From: Shawn Erickson <email@hidden>)
 >Re: When do I need to override hash? (From: Clark Cox <email@hidden>)
 >Re: When do I need to override hash? (From: Kyle Sluder <email@hidden>)
 >Re: When do I need to override hash? (From: Clark Cox <email@hidden>)
 >Re: When do I need to override hash? (From: Alastair Houghton <email@hidden>)
 >Re: When do I need to override hash? (From: Seth Willits <email@hidden>)
 >Re: When do I need to override hash? (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: When do I need to override hash?
  • Next by Date: Re: When do I need to override hash?
  • 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