commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <bali...@centras.lt>
Subject Re: [Collections][SUBMIT] ReferenceMap...take 3...
Date Fri, 19 Jul 2002 17:57:35 GMT
Hi,


> > Is there a compelling reason why the autoPurge method uses
> > the internal structure of the Map?  It looks like it could
> > just synchronize properly and call purge(); thus it could
> > be implemented in MapUtils as a decorator.
>
> A map created by autoPurge removes mappings as soon as
> the garbage collector enqueues the References; the mappings
> are removed as soon as possible.  To do so it requires
> access to the internal ReferenceQueue.
>
> The method you describe would require the background thread
> to wake up periodically and call purge(), which would mean
> some extra lag time.

I prefer to call purge in map metods like "get", "pu" (WeakHashMap doe's the
same ). JVM runs some internal thread itself for references.


>
> > How is the hashing performance?  It looks like you're going
> > to run into the problems discussed previously on this list,
> > where most objects that  don't customize their hashCode method
> > will hash to the same buckets.  That is, if the hashCode is just
> > some memory address (e.g. a multiple of 8), you'll hash all the
> > objects into the same (tablesize/8) buckets.
>
> Well, I just copied the algorithms from java.util.WeakHashMap,
> so there really wasn't much thought put into the hash function.
>
> What algorithm would you suggest?
Some "good" algorithms  are "slow" itself  there are a lot of algorithms,
the most popular is this :

 hash := ( M - 2  - x ) mod ( M - 2 )   // M and ( M - 2 ) are prime numbers
"Twins"


prime numbers can be generated and hardcoded in static array, it is
recomended to use
exponent sequence fo this table:

 M(i + 1) >= M(i)*C  // C > 1, M(i) and ( M(i) - 2 ) are prime numbers

this is a good resource:
http://pauillac.inria.fr/algo/AofA/







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


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


Mime
View raw message