哈希表/字典碰撞 [英] Hashtable/Dictionary collisions

查看:140
本文介绍了哈希表/字典碰撞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用标准的英文字母和下划线只是,有多少字符可以在最大使用而不会在一个哈希表/字典可能会发生碰撞。

Using the standard English letters and underscore only, how many characters can be used at a maximum without causing a potential collision in a hashtable/dictionary.

所以串状

blur
Blur
b
Blur_The_Shades_Slightly_With_A_Tint_Of_Blue

...

推荐答案

有没有保证你不会得到单个字母之间的冲突。

There's no guarantee that you won't get a collision between single letters.

您的可能的不会,但在 string.GetHashCode 未指定,并可能改变。 (特别是.NET 1.1和.NET 2.0,烧毁谁承担它不会改变人们之间的变化。)

You probably won't, but the algorithm used in string.GetHashCode isn't specified, and could change. (In particular it changed between .NET 1.1 and .NET 2.0, which burned people who assumed it wouldn't change.)

请注意,散列码冲突不会停止精心设计的哈希表的工作 - 你应该仍然能够得到正确的价值观时,它会只是可能需要检查使用相等多个键,如果他们已经得到了相同的散列码

Note that hash code collisions won't stop well-designed hashtables from working - you should still be able to get the right values out, it'll just potentially need to check more than one key using equality if they've got the same hash code.

这依赖于散列码是唯一的字典为缺少有关哈希码的重要信息,国际海事组织:)(除非是下操作的非常的具体条件,其中这是绝对的知道的他们会是唯一的,也就是说,它的使用完善哈希函数 。)

Any dictionary which relies on hash codes being unique is missing important information about hash codes, IMO :) (Unless it's operating under very specific conditions where it absolutely knows they'll be unique, i.e. it's using a perfect hash function.)

这篇关于哈希表/字典碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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