Shouldn't HashSet/Map use Arrays.hashCode(x[]) ?

Martin Buchholz martinrb at google.com
Fri Jun 4 18:26:34 UTC 2010


Aside from the fact that it would be a hugely incompatible change
to change the hashing/equality algorithm now,
it is quite a religious argument about which is the Right Thing to do.

Here's some religion/philosophy for you:
http://home.pipeline.com/~hbaker1/ObjectIdentity.html

There are some existing collections, e.g. BlockingQueues,
that use identity comparison instead of content comparison.

Martin

On Fri, Jun 4, 2010 at 08:49, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
> Otherwise e.g. int[] as key for HashSet/Map doesn't make any sense.
>
> I use a class where the content of an int[] defines the uniqueness or there
> instances.
> Before I create a new instance, I have to check if there is just one for the
> same int[] content.
> Using the current HashSet/Map implementation does not serve this need.
> It seems, that I should first instantiate a temporary object containing the
> int[], hash it in the set/map, and later throw it away. :-(
>
> Maybe another reason for solving
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6812862
>
> -Ulf
>
>
>



More information about the core-libs-dev mailing list