Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!53ab2750!not-for-mail From: "Arne Vajhøj" Subject: Re: hashCode Message-ID: <5027F2C9.56694.calajapr@time.synchro.net> X-Comment-To: Roedy Green Newsgroups: comp.lang.java.programmer In-Reply-To: <50269FD1.56651.calajapr@time.synchro.net> References: <50269FD1.56651.calajapr@time.synchro.net> X-FTN-AREA: COMP.LANG.JAVA.PROGRAMMER X-FTN-MSGID: 1:261/38 74ca74ba X-FTN-REPLY: 1:261/38 8dbf78a7 Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.16a-Win32 NewsLink 1.98] Lines: 34 Date: Sun, 12 Aug 2012 18:58:18 GMT NNTP-Posting-Host: 69.21.70.65 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1344797898 69.21.70.65 (Sun, 12 Aug 2012 13:58:18 CDT) NNTP-Posting-Date: Sun, 12 Aug 2012 13:58:18 CDT Organization: tds.net X-Received-Bytes: 2082 Xref: csiph.com comp.lang.java.programmer:17750 To: Roedy Green From: Arne Vajhoj On 8/11/2012 7:54 AM, Roedy Green wrote: > On Fri, 10 Aug 2012 12:45:07 -0700 (PDT), Lew > wrote, quoted or indirectly quoted someone who said : > >> h =3D 31 * h + attribute.hashCode(); >> } > In my essay I recommend XOR which is an inherentely faster operation > than multiply. I wonder which actually works out better. Multiply. XOR has several problems: - many small values give small result - same values in different fields give same result - two identical values give result zero + all those I did not think of. > If you had a > large number of fields, the multiply effect could fall off the left > hand end. It is the algorithm used for String which could have very > long strings, so Sun must have thought of that. The multiply effect does not fall off the left with a value like 31 (it would with 32). Arne --- BBBS/Li6 v4.10 Dada-1 * Origin: Prism bbs (1:261/38) --- Synchronet 3.16a-Win32 NewsLink 1.98 Time Warp of the Future BBS - telnet://time.synchro.net:24