On Saturday 05 April 2008 01:12, Daniel Cheng wrote:
> On Sat, Apr 5, 2008 at 2:12 AM, Matthew Toseland
> <toad at amphibian.dyndns.org> wrote:
> > On Friday 04 April 2008 06:25, you wrote:
> > > Author: nextgens
> > > Date: 2008-04-04 05:25:41 +0000 (Fri, 04 Apr 2008)
> > > New Revision: 18968
> > >
> > > Modified:
> > >    trunk/freenet/src/freenet/crypt/DSAPublicKey.java
> > > Log:
> > > implement DSAPublicKey.hashCode()
> > >
> > > Modified: trunk/freenet/src/freenet/crypt/DSAPublicKey.java
> > > ===================================================================
> > > --- trunk/freenet/src/freenet/crypt/DSAPublicKey.java 2008-04-04 
05:21:19
> > UTC (rev 18967)
> > > +++ trunk/freenet/src/freenet/crypt/DSAPublicKey.java 2008-04-04 
05:25:41
> > UTC (rev 18968)
> > > @@ -163,6 +163,13 @@
> > >               return y.equals(o.y) && group.equals(o.group);
> > >       }
> > >
> > > +     public int hashCode() {
> > > +             int hash = 5;
> > > +             hash = 61 * hash + (this.y != null ? this.y.hashCode() : 
0);
> > > +             hash = 61 * hash + (this.group != null ? 
this.group.hashCode() : 0);
> > > +             return hash;
> > > +     }
> >
> > Arcane maths should really be justified in comments! Is this something you
> > just made up or is there a reason for not just returning the xor of y and
> > group's hash codes? Also, in what cases can they be null anyway? If they
> > cease to be null, the hash code would change ... but aren't they final?
> 
> I guess these are generated by IDE.
> This is the standard pattern in the "Effective Java " book.

It's all prime numbers... does it make the first few bits more dependant on y 
than on group? It looks like it, so I will change it to just xor them.
> 
> > > +
> > >       public boolean equals(Object o) {
> > >               if(this == o) // Not necessary, but a very cheap 
optimization
> > >                       return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20080405/c1dd71ec/attachment.pgp>

Reply via email to