Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

How can we improve the performance of IdentityHashMap?

Pragya Keshap answered on February 4, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


How can we improve the performance of IdentityHashMap?

0

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.

https://www.baeldung.com/java-hashmap-optimize-performance

Popularity 1/10 Helpfulness 1/10 Language java
Source: Grepper
Link to this answer
Share Copy Link
Contributed on Feb 04 2023
Pragya Keshap
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.