Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New JavaRanch Journal article: Supercharging your HashMaps

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The latest issue of the JavaRanch Journal contains an article by David O'Meara on Supercharging your HashMaps. Go read it while it's fresh, and discuss it in this thread.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not particularly ground breaking I admit, but if anyone has any comments on the "Unusual Iteration Times" mentioned in the after thoughts, I haven't had a chance to dig deeper and would appreciate opinions.
 
Manuel Laflamme
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Map iteration is traversing the whole map entry table. If your initial capacity is 1,000,000 the iterator have to traverse all the 1,000,000 entries (2^20 actually) even if only a small subset of them contain values. So your test with initial capacity of 1,000,000 and 1,000 keys is actually doing 10,000 iteration x 1,000,000 entries rather than 10,000 x 1,000.
[ July 31, 2008: Message edited by: Manuel Laflamme ]
 
Campbell Ritchie
Sheriff
Pie
Posts: 48940
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to JavaRanch, Manuel Laflamme
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome also

Understood, but if you look at Table 5, we expect the iteration time to increase when increasing the initial capacity, what I wasn't expecting was the iteration time to decrease for a given capacity when the Map contains more items

ie


In the above, the actual capacity should be the same in each case (2^20) but the iteration time decreases with the increasing size of data held in the HashMap, or so it would appear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic