Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up2.2.8 小节对HashMap树化的描述有一点问题 #735
Open
Comments
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
作者在 JDK1.8之后 这一小节的开头中写道:
这段话加粗部分的描述是不准确的,当链表长度大于阈值时,会尝试调用树化方法
treeifyBin,但这不意味着会将链表转为树:当我们查看树化方法
treeifyBin(JDK1.8 HashMap源码)时,应注意到这么一行代码(757行):我们发现,当哈希表的
length小于MIN_TREEIFY_CAPACITY(默认为64)时,并不会真正树化,而只是执行resize(),也就是扩容的操作,这一点在对树化方法treeifyBin以及MIN_TREEIFY_CAPACITY的注释中都有提到:
如果我的看法有什么错漏之处,恳请大家补充指正