I use ConcurrentHashMap as my data structure because mutiple threads will read and write at the same time. But I find that client code will also have to iterate through it often. So I took a look at the LinkedHashMap class, which gives the best iteration performance, and found this section in my java document:
A linked hash map has two parameters that affect its performance: initial power and load factor. They are defined exactly the same as for HashMap. Note, however, that the penalty for selecting an excessively high value for this class for the initial capacity is less severe than for HashMap, since the iteration time for this class is independent of capacity.
So the iteration is independent of capacity. What other operations depend on the initial capacity for LinkedHashMap or HashMap in general? Also, is there any parallel version of LinkedHashMap in recent versions of the JDK?
source share