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.
So strings like:
blur Blur b Blur_The_Shades_Slightly_With_A_Tint_Of_Blue
…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no guarantee that you won’t get a collision between single letters.
You probably won’t, but the algorithm used in
string.GetHashCodeisn’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.)