Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[collections-dev] Question about UnifiedMap

Hello,

I am trying to understand how does the UnifiedMap (UM) differ from the built-in HashMap that comes with Java. I read these two pages:
https://medium.com/oracledevs/unifiedmap-how-it-works-48af0b80cb37
https://eclipse.dev/collections/javadoc/9.0.0/org/eclipse/collections/impl/map/mutable/UnifiedMap.html

but am still confused and have some questions:

1. Quoting: "The array contains the key value pairs in consecutive slots, just like the main array, but it's a linear list with no hashing." ---> does this mean UM does not use getHashCode? the other link says: "Since UnifiedMap does not cache the hashcode, for each look up, hashcode needs to be computed. So, the performance of UnifiedMap is directly dependent on the hashcode implementation of the key." Btw, I don't think the Java HashMap caches the hashcode either. It has to be computed for every lookup. otherwise we are running into a circular problem. what data structure will be used to cache the hascode?

2. if there is no hashing then how does UM search for a key? are the keys stored in sorted order and does it perform a binary search?

i have more questions but want to start with these to get some clarity. can i get link to the source code of UM?

Thanks,

M.



Back to the top