为什么净字典大小调整为质数? [英] Why .Net dictionaries resize to prime numbers?

查看:137
本文介绍了为什么净字典大小调整为质数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这个问题一个.net字典尺寸调整其分配的空间,以素数是至少两倍的当前大小。为什么重要的是使用素数,而不仅仅是两倍电流的大小? (我试图用我的谷歌福的权力,找到一个答案,但无济于事)

According to this question a .Net dictionary resizes its allocated space to prime numbers that are at least twice the current size. Why is it important to use prime numbers and not just twice the current size? (I tried to use my google-fu powers to find an answer, but to no avail)

推荐答案

这是一种算法,实现细节相关的选择一个好的哈希函数并提供均匀分布。的非均匀分布增加了冲突数,和它们的解析的成本。

It is an algorithm implementation detail related to choosing a good hashing function and which provides uniform distribution. A non-uniform distribution increases the number of collisions, and the cost of resolving them.

这篇关于为什么净字典大小调整为质数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆