Re: hashCode

Discussion in 'Java' started by Arne Vajhøj, Aug 13, 2012.

  1. To: Patricia Shanahan
    From: "=?UTF-8?B?QXJuZSBWYWpow7hq?=" <=?utf-8?b?qxjuzsbwywpow7hq?=@1:261/38.rem
    ove-nlb-this>

    To: Patricia Shanahan
    From: =?UTF-8?B?QXJuZSBWYWpow7hq?= <>

    On 8/12/2012 12:40 PM, Patricia Shanahan wrote:
    > Keeping hashCode as an Object method but making it useless for bucket
    > selection unless overridden would not be a good alternative.
    >
    > A more reasonable alternative would be to have hashCode as the only
    > member of a HashKey interface that would be implemented by every class
    > whose objects are intended to be suitable for use as has keys. Those
    > objects that have a hashCode would still have to have a usable one, but
    > some classes would not implement HashKey and not have a hashCode at all.


    That would avoid using the hash for classes where it does not make much sense.

    I like it.

    Given that there is a gazillion lines of code out there that stores Object,
    then it can not be changed.

    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

    --- 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
    Arne Vajhøj, Aug 13, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roedy Green

    hashCode for byte[]

    Roedy Green, Aug 22, 2003, in forum: Java
    Replies:
    1
    Views:
    413
    Dale King
    Aug 22, 2003
  2. Marco
    Replies:
    10
    Views:
    754
  3. Gregory A. Swarthout

    equals and hashCode

    Gregory A. Swarthout, Dec 19, 2003, in forum: Java
    Replies:
    2
    Views:
    337
    Silvio Bierman
    Dec 20, 2003
  4. kelvSYC

    Designing hashCode() methods

    kelvSYC, Dec 23, 2003, in forum: Java
    Replies:
    1
    Views:
    355
    Ulrich Stern
    Dec 24, 2003
  5. Dimitri Pissarenko

    Hashcode of primitive types

    Dimitri Pissarenko, Jan 29, 2004, in forum: Java
    Replies:
    5
    Views:
    5,808
    Hylander
    Jan 29, 2004
Loading...

Share This Page