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

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

问题描述

根据此问题,一个.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.

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

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