HashMap put 流程图解
2023-05-29 15:07:43 0 举报
登录查看完整内容
HashMap put 流程图解,过程全解析
作者其他创作
大纲/内容
N
table==null或table.length==0
Y
覆盖value
key是否存在
++size > threshold
判断链表长度>8
根据key计算hash,得到数组下标
resize扩容
Start
转换红黑树
插入链表尾部
returnnull
插入数组
table[i]是否为TreeNode
遍历红黑树
遍历链表
table == null或table.length < 64
++modCount
插入红黑树
return oldValue
table[i]==null
put / putVal
![HashMap扩容流程图解](https://www.processon.com/chart_image/template/thumb/6482820176213168c2f62418.png?tid=64772e3df2ad6e727082ec2e)
收藏
![HashMap put 流程图解](https://www.processon.com/chart_image/template/thumb/6474638476213118f3ff59fb.png?tid=64731ecd10476629fb85020b)
收藏
0 条评论
回复 删除
下一页