Hashtable/Dictionary collisions

后端 未结 5 1178
孤街浪徒
孤街浪徒 2021-01-06 11:39

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.

5条回答
  •  渐次进展
    2021-01-06 12:12

    If your key is a string (e.g., a Dictionary) then it's GetHashCode() will be used. That's a 32bit integer. Hashtable defaults to a 1 key to value load factor and increases the number of buckets to maintain that load factor. So if you do see collisions they should tend to occur around reallocation boundaries (and decrease shortly after reallocation).

提交回复
热议问题