HashSet加载因子 [英] HashSet load factor
问题描述
如果我使用 HashSet
,初始容量为10,加载因子为0.5
,则每5个元素添加 HashSet
将会增加,或者首先 HashSet
增加10个元素,然后在15 at at 20 atc增加。容量会增加吗?
负载系数衡量HashSet在容量增加之前的充足程度自动增加。当哈希表中的条目数超过加载因子和当前容量的乘积时,哈希表将被重新哈希(即,重建内部数据结构),以便哈希表具有大约两倍的桶数。 / p>
If I use a HashSet
with a initial capacity of 10 and a load factor of 0.5
then every 5 elements added the HashSet
will be increased or first the HashSet
is increased of 10 elements and after at 15 at 20 atc. the capacity will be increased?
The load factor is a measure of how full the HashSet is allowed to get before its capacity is automatically increased. When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the hash table is rehashed (that is, internal data structures are rebuilt) so that the hash table has approximately twice the number of buckets.
这篇关于HashSet加载因子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!