This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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 ]
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
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.