Hi,
Where can I find information about the performance of the
nextProbablePrime() method in the java.math.BigInteger class? The
relates to the initial capacity of a HashMap.
The HashMap that can hold data of at least size X and at most Y,
and I want to set the initial capacity to the next possible prime
between X and Y.
By the way Y = X * 2.
At the moment I am setting the capacity to X but I've read that
HashMaps perform better if the initial capacity is a prime number - I
want to test this.
Thanks,
Chris
Thomas Hawtin - 16 May 2006 12:20 GMT
> At the moment I am setting the capacity to X but I've read that
> HashMaps perform better if the initial capacity is a prime number - I
> want to test this.
The current implementation of java.util.HashMap (in Sun JREs) always
rounds up to a power of two.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Jeffrey Schwab - 16 May 2006 22:27 GMT
>> At the moment I am setting the capacity to X but I've read that
>> HashMaps perform better if the initial capacity is a prime number - I
>> want to test this.
>
> The current implementation of java.util.HashMap (in Sun JREs) always
> rounds up to a power of two.
So for the best performance, start with a capacity of two. ;)
Roedy Green - 21 May 2006 19:20 GMT
>At the moment I am setting the capacity to X but I've read that
>HashMaps perform better if the initial capacity is a prime number - I
>want to test this.
Hashtables do, but HashMaps round up to a power of two.
See http://mindprod.com/jgloss/hashtable.html
http://mindprod.com/jgloss/hashmap.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.