2006-01-27, 07:31 PM
For my SuDoku plugin I maintain two two-dimensional int arrays, i.e., defined as int[,] not of type Array. One is the answer 'grid' and contains what the player should be trying to reach, the other is the playing 'grid' and contains whatever they have filled in so far along the way plus the numbers which were prefilled for them.
Whenever a number key is pressed, I compare the answer grid to the playing grid, element by element, which seems inefficient to do.
What I've read about object.GetHashCode suggests that if I compare the hash code of each array and they DON'T match, I can be guaranteed that the data in the two arrays don't match. If the hash codes DO match, however, it suggests the data in the arrays do match but I should perform a definitive element-by-element comparison to be sure.
Does that make sense?
Whenever a number key is pressed, I compare the answer grid to the playing grid, element by element, which seems inefficient to do.
What I've read about object.GetHashCode suggests that if I compare the hash code of each array and they DON'T match, I can be guaranteed that the data in the two arrays don't match. If the hash codes DO match, however, it suggests the data in the arrays do match but I should perform a definitive element-by-element comparison to be sure.
Does that make sense?