commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <p...@steitz.com>
Subject Re: [collections] ReferenceMap changed for WeakIdentityMap but now broken
Date Tue, 30 Mar 2004 05:31:18 GMT

I think the problem may be in the first line below.  I don't think you 
want to hash the reference.  If you change hash(ref) to ref.hashCode() all 
tests (including commented out ones) succeed.

> 
>     private void purge(Reference ref) {
>         // The hashCode of the reference is the hashCode of the
>         // mapping key, even if the reference refers to the 
>         // mapping value...
>         int hash = hash(ref);
>         int index = hashIndex(hash, data.length);
>         HashEntry previous = null;
>         HashEntry entry = data[index];
>         while (entry != null) {
>             if (((ReferenceEntry) entry).purge(ref)) {
>                 if (previous == null) {
>                     data[index] = entry.next;
>                 } else {
>                     previous.next = entry.next;
>                 }
>                 this.size--;
>                 return;
>             }
>             previous = entry;
>             entry = entry.next;
>         }
> 
>     }





---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message