[concurrency-interest] CHM, key/entry.key equality test, and reference maps

Andreou Dimitris jim.andreou at gmail.com
Thu Dec 25 11:45:10 EST 2008


Hi,

In CHM (as also in HashMap), when a get() occurs, the equality test 
happens like "key.equals(entry.key))". Is there any reason that forbids 
the inverse route to be taken? (This question extends to value equality 
tests too).

It seems to me that, from the correctness of CHM point of view, it 
doesn't matter. Yet, I think that if it was consistently implemented the 
other way, then anyone could built an extension that transparently 
offers any kind of indirection in keys and values (like a reference map 
does), without pushing to the reader the burden of creating keys with 
special knowledge about the indirection (i.e. no need for dummy 
objects). Instead, only the writer would define equality for wrapped 
values it creates (by delegating to the unwrapped values), letting 
readers be faster.

So, what do I miss there?

Thanks,
Dimitris Andreou


More information about the Concurrency-interest mailing list