Hello, i'm new here, so let me say hello :)
i'm at page 249, (hashtables) and it lays down the rules of making a GetHashCode() method, which i'm having a hard time understanding.
"It should be fast...."
ok, i guess this means that i should keep the algorithm simple. right?
"It must be consistent..."
i understand that too, if two keys are reffering to the same value, then they should generate the same hash (since the value is indentified by it's hash)
but i don't understand this:
"It should give values that are likely to be distributed across the entire range of numbers that an int can store"
i don't understand what this means. does that mean that the algorithm shouldn't give numbers that are out of bounds? - it doesn't seem so from the explanation:
"The reason for this last condition is because of a potential problem: what happens if you get two entries in the dictionary whose hashes both give the same index"
i have no idea what this means - does it mean that the GetHashCode() has assigned the same number for 2 different indexes?
and if this is the case then what can be done about it? and wouldn't the program crash (since it doesn't know which entry to refer to) rather than just experience a performance hit?