【java】【05】HashMap 当链表长度为8的时候转红黑树

1.当包箱中节点个数是8时,才使用TreeNodes

Because TreeNodes are about twice the size of regular nodes, we
use them only when bins contain enough nodes to warrant use
(see TREEIFY_THRESHOLD).
因为TreeNodes占用的空间大约是常规节点的两倍,我们
仅当存储箱包含足够的节点以保证使用时才使用它们
(参见TREEIFY_THRESHOLD)
static final int TREEIFY_THRESHOLD = 8;

2.当包箱中包含的节点很少时,会转换成普通包箱

And when they become too small (due to
removal or resizing) they are converted back to plain bins.
当它们变得太小(由于移除或调整大小)它们被转换回普通的箱子。

3.很少会使用到红黑树,根据泊松分布,大于8的概率为一千万分之一

In usages with well-distributed user hashCodes, tree bins are
rarely used.
在使用分布良好的用户哈希码时,树状容器是很少使用

Ideally, under random hashCodes, the frequency of nodes in bins follows a Poisson distribution
(http://en.wikipedia.org/wiki/Poisson_distribution) with a
parameter of about 0.5 on average for the default resizing
threshold of 0.75, although with a large variance because of
resizing granularity.

理想情况下,在随机哈希码下容器中的节点遵循泊松分布(http://en.wikipedia.org/wiki/Poisson_distribution)
带着默认大小调整的平均值约为0.5阈值为0.75,尽管由于调整粒度大小。

Ignoring variance, the expected occurrences of list size k are (exp(-0.5) * pow(0.5, k) /factorial(k)).
忽略误差,期望列表大小k的出现次数为(exp(-0.5) * pow(0.5, k) / factorial(k))。factorial 阶乘

The first values are:
0: 0.60653066
1: 0.30326533
2: 0.07581633
3: 0.01263606
4: 0.00157952
5: 0.00015795
6: 0.00001316
7: 0.00000094
8: 0.00000006
more: less than 1 in ten million
更多的话,小于 一千万分之1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值