• Post Reply Bookmark Topic Watch Topic
  • New Topic

HashSet initial capacity and load factor  RSS feed

 
Tim Cerillo
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I know that I will load 1.6 million userids (one column) on a HashSet, how can I compute for the initial capacity and the load factor?

Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ideal initialCapacity would be the number of unique IDs. The load factor can be, as virtually always, just left at the default.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
The ideal initialCapacity would be the number of unique IDs.


Shouldn't it be

#ids / load factor

?

That is, with 1.6 million ids and a load factor of 0.75 (I think that's the default?) it should be 2.2 million.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!