1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-08-01 16:28:03 +08:00

Update java-collection-questions-02.md

注释,由 “如果链表元素个数大于等于TREEIFY_THRESHOLD(8)” 改为“如果链表元素个数大于TREEIFY_THRESHOLD(8)”。
个人认为,等于8时,并没有考虑转红黑树。
This commit is contained in:
Mr. Confidence 2024-05-13 22:43:12 +08:00 committed by GitHub
parent ff1db4debb
commit f87f16a081
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -239,7 +239,7 @@ for (int binCount = 0; ; ++binCount) {
// 遍历到链表最后一个节点
if ((e = p.next) == null) {
p.next = newNode(hash, key, value, null);
// 如果链表元素个数大于等于TREEIFY_THRESHOLD8
// 如果链表元素个数大于TREEIFY_THRESHOLD8
if (binCount >= TREEIFY_THRESHOLD - 1) // -1 for 1st
// 红黑树转换(并不会直接转换成红黑树)
treeifyBin(tab, hash);