aspose file tools*
The moose likes Java in General and the fly likes New JavaRanch Journal article: Supercharging your HashMaps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "New JavaRanch Journal article: Supercharging your HashMaps" Watch "New JavaRanch Journal article: Supercharging your HashMaps" New topic
Author

New JavaRanch Journal article: Supercharging your HashMaps

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
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.


Ping & DNS - my free Android networking tools app
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Jul 31, 2008
Posts: 1
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

Joined: Oct 13, 2005
Posts: 38818
    
  23
. . . and welcome to JavaRanch, Manuel Laflamme
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New JavaRanch Journal article: Supercharging your HashMaps