Generate a commutative hash based on three sets of numbers?
- by DarkAmgine
I need to generate a commutative hash based on three sets of "score" structs.
Each score has a "start", an "end" and a "number".
Both start and end are usually huge numbers (8-9 digits) but number is just from 1 to 4.
I need them to be commutative so the order does not matter. I'm using XOR at the moment but it seems to be giving bad results.
Since I'm working with large large datasets, I'd prefer a performance-friendly solution.
Any suggestions? Thanks =]
public static int getCustomHash(cnvRegion c1, cnvRegion c2, cnvRegion c3)
{
int part1 = (c1.startLocation * c2.startLocation * c3.startLocation);
int part2 = (c1.endLocation * c2.endLocation * c3.endLocation);
int part3 = (c1.copyNumber + c2.copyNumber + c3.copyNumber)*23735160;
return part1 ^ part2 ^ part3;
}