[concurrency-interest] ConcurrentHashMapV8

√iktor Ҡlang viktor.klang at gmail.com
Mon Oct 3 10:59:08 EDT 2011


On Mon, Oct 3, 2011 at 4:22 PM, Mark Thornton <mthornton at optrak.com> wrote:

> On 03/10/11 14:34, √iktor Ҡlang wrote:
>
>> Hi Doug,
>>
>> I'd love to be able to specify a Comparator in the constructor so that
>> conditional remove doesn't rely on reference-equality or .equals (since
>> oftentimes I cannot overload it)
>>
>> Thoughts?
>>
>> Cheers,
>>>>
> A Comparator wouldn't be appropriate for a HashMap.


Appropriate? You mean just like doing a DNS lookup in the equals of
java.net.URL?


> What you need is something like:
>
> interface Equivalence<T> {
>    int hash(T value);
>    boolean isEqual(T a, T b);
> }
>

What does hashes have to do with equivalence? Is that appropriate?

interface Hashable<T> {
  int computeHashFor(T value);
}

interface Equivalence<T> {
  boolean isEqual(T a, T b);
}

and then require something that implements both Hashable<K> and
Equivalence<V>

Cheers,
√


>
> Mark
>
>
> ______________________________**_________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.**oswego.edu <Concurrency-interest at cs.oswego.edu>
> http://cs.oswego.edu/mailman/**listinfo/concurrency-interest<http://cs.oswego.edu/mailman/listinfo/concurrency-interest>
>



-- 
Viktor Klang

Akka Tech Lead
Typesafe <http://www.typesafe.com/> - Enterprise-Grade Scala from the
Experts

Twitter: @viktorklang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20111003/16a72708/attachment-0001.html>


More information about the Concurrency-interest mailing list