Article View: comp.sys.next.programmer
Article #71equality and hashing of objects
From: Paul Burchard
Date: Fri, 30 Oct 1992 07:24
Date: Fri, 30 Oct 1992 07:24
21 lines
1436 bytes
1436 bytes
I've created a class which redefines the -isEqual: method. I'd like to be able to put such objects into HashTables. The documentation seems to make this logically impossible. HashTable says: If two keys are equal in the sense of isEqual:, then their hashed values must be equal. But Object says: - (unsigned int)hash [...] The integer is guaranteed to always be the same for the same id. Hmmm....so if my -isEqual: comparison depends only on the contents of objects, not their id's, then the only -hash method allowed is one that returns a constant value! That's a pretty rough restriction for a hash function... Can anyone clear up this contradiction? -- -------------------------------------------------------------------- Paul Burchard <burchard@geom.umn.edu> ``I'm still learning how to count backwards from infinity...'' --------------------------------------------------------------------
Technical Details
Message-ID:
<1992Oct30.072447.13751@news2.cis.umn.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!src.honeywell.com!The-Star.honeywell.com!umn.edu!newsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!uwm.edu!src.honeywell.com!The-Star.honeywell.com!umn.edu!news From: burchard@geom.umn.edu (Paul Burchard) Newsgroups: comp.sys.next.programmer Subject: equality and hashing of objects Message-ID: <1992Oct30.072447.13751@news2.cis.umn.edu> Date: 30 Oct 92 07:24:47 GMT Article-I.D.: news2.1992Oct30.072447.13751 Sender: news@news2.cis.umn.edu (Usenet News Administration) Organization: University of Minnesota Lines: 21 Nntp-Posting-Host: descartes.geom.umn.edu