In HashMap why threshold value (The next size value at which to resize) is capacity * load factor. Why not as equal to size or capacity of map

前端 未结 4 782
悲&欢浪女
悲&欢浪女 2021-02-05 22:59

In HashMap why threshold value (The next size value at which to resize) is capacity * load factor. Why not as equal to size or capacity

4条回答
  •  爱一瞬间的悲伤
    2021-02-05 23:37

    From a theory perspective, the likelihood of maintaining no collisions with a full hash table is very low, so hash tables will be resized to maintain their desired O(1) lookup property - less collisions means more direct access to entries and less searching.

提交回复
热议问题