Why is there no Dictionary.TrimExcess()?

后端 未结 5 1526
醉梦人生
醉梦人生 2021-02-14 08:03

In .NET, there is a constructor for Dictionary that takes one parameter, int capacity. This is the same as with many other collecti

5条回答
  •  忘了有多久
    2021-02-14 08:15

    I'd guess that in this case the capacity argument helps define the hashing function as well as the number of buckets; resizing/trimming a sparse collection of data would require recalculating hashes of all of the stored items remaining.

提交回复
热议问题