1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

update hashmap-source-code.md

This commit is contained in:
jun 2023-08-01 17:08:33 +08:00
parent 9d802717c2
commit 07a085285b

View File

@ -453,7 +453,8 @@ final Node<K,V>[] resize() {
// 只有一个节点,直接计算元素新的位置即可 // 只有一个节点,直接计算元素新的位置即可
newTab[e.hash & (newCap - 1)] = e; newTab[e.hash & (newCap - 1)] = e;
else if (e instanceof TreeNode) else if (e instanceof TreeNode)
// 将红黑树拆分成2棵子树拆分后的子树节点数小于等于6则将树转化成链表 // 将红黑树拆分成2棵子树如果子树节点数小于等于 UNTREEIFY_THRESHOLD默认为 6则将子树转换为链表。
// 如果子树节点数大于 UNTREEIFY_THRESHOLD则保持子树的树结构。
((TreeNode<K,V>)e).split(this, newTab, j, oldCap); ((TreeNode<K,V>)e).split(this, newTab, j, oldCap);
else { else {
Node<K,V> loHead = null, loTail = null; Node<K,V> loHead = null, loTail = null;