HashSet load factor

前端 未结 3 1257
Happy的楠姐
Happy的楠姐 2021-02-04 03:34

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

3条回答
  •  遇见更好的自我
    2021-02-04 04:00

    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.

    source

提交回复
热议问题