On Aug 20, 2009, at 12:00 PM, Seth Willits wrote:
From the docs:
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 thehash method of the object must not change while the object is in the collection. Therefore, either the hash method must not rely on any of the object’s internal state information or you must make sure the object’s internal state information does not change while the object is in the collection.

That's pretty hard to deal with.

Returning 0 is certainly simpler :p

Simpler, but slower. Performance of NSSet and NSDictionary in particular will drop dramatically if the -hash values of unequal keys are always the same.

If two objects are -isEqual: to each other, then they MUST have the same -hash value. NSSet and NSDictionary will behave incorrectly if you do this wrong for their keys.

If two objects are not -isEqual: to each other, then they SHOULD have different -hash values. They MAY have the same -hash value, but NSSet and NSDictionary will be slower if that happens too often.


--
Greg Parker     gpar...@apple.com     Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to