IdentityHashMap class has one tuning parameter for performance
improvement: expectedMaxSize.
This parameter is the maximum number of key-value mappings that
the map is expected to hold.
We can use this parameter is used to determine the number of
buckets initially in the hash table. The precise relationship between
the expected maximum size and the number of buckets is
unspecified.
If the number of key-value mappings exceeds the expected maximum
size, the number of buckets is increased.
Increasing the number of buckets is also known as rehashing.
Rehashing may be fairly expensive. So it is better to create identity
hash maps with a sufficiently large expected maximum size.
But iteration over a Map collection requires time proportional to
the number of buckets in the hash table. So iteration may take extra
time due to large number of buckets.
Therefore the value of expectedMaxSize should be set in
consideration with both of these aspects.