commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [collections] ReferenceMap changed for WeakIdentityMap but now broken
Date Thu, 01 Apr 2004 00:15:25 GMT
Thanks Phil, that was the problem. ReferenceMap now extends
AbstractHashedMap ;-)
Stephen

----- Original Message -----
From: "Phil Steitz" <phil@steitz.com>
> 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


---------------------------------------------------------------------
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