I have the following class:
public class Foo
{
int year;
string name;
int category;
}
Here is some example data:
2012 Test1 1000
2012 Test2 1000
2012 Test3 1000
2012 Test4 1000
2012 Test4 10
...
If I override GetHashCode all results are very similiar:
return year ^ name ^ category;
int hash = 13;
hash = hash * 33 + year.GetHashCode();
hash = hash * 33 + name.GetHashCode();
hash = hash * 33 + category.GetHashCode();
return hash;
What is a good hash function (with maximal distribution) for this situation?
Edit: Perhaps my understanding of the hash buckets is wrong. Go similar hash values to the same bucket?
"Test1".GetHashCode() --> -1556460260
"Test2".GetHashCode() --> -1556460257