Why do we need the hashcode and bucket concept in LinkedHashMap

Recently, I went through the interface Mapin java. I understood HashMap, and everything made sense. But when it comes down to LinkedHashMap, as I know so far, Entry has key, value, beforeand after. where before and after monitors the insertion order.

However, using hashcodethe bucket concept does not make sense to me LinkedHashMaps.

I looked through this article to understand the implementation of related HashMaps

Can someone explain this?

+4
source share
1 answer

LinkedHashMap - HashMap. , HashMap, , ( , get(), put(), containsKey() ..). hashCode() . O(1) .

LinkedHashMap ( before after) , Collection, keySet(), entrySet() values(). , .

- LinkedHashMap Map O(1) .

+6

Source: https://habr.com/ru/post/1693964/


All Articles