IdentityHashCode in HashMap's bucket

前端 未结 3 1225
眼角桃花
眼角桃花 2021-01-04 19:33

In the implementation details of HashMap, I can read:

When using comparators on insertion, to keep a
 * total ordering (or as close as is requir         


        
3条回答
  •  猫巷女王i
    2021-01-04 20:13

    No, you are moving entries to left or right indeed based on System::identityHashCode but in that bucket there are entries still that have the same hashCode (well not the same, only the portion that matters).

    So when you search for something it sometimes has to look at both left and right, there is no way around it, as simple as that.

提交回复
热议问题