On 7/31/2013 1:49 AM, Dmitry Olshansky wrote:
Here key is 32 bits. Surely 2 strings can hash to the exact same 32 bit value.
No, they cannot. The "hash value" is a pointer to the string. The strings are already inserted into another hash table, so all strings that are the same are combined. Therefore, all unique strings "hash" to unique values.
This resolves only slot collision. It doesn't resolve full hash collision.
If it was broken the compiler wouldn't work at all :-)