Let's say I have a structure like this,
struct point3d{
int x;
int y;
int z;
};
How can I create a hash value from this structure? Thanks
Let's say I have a structure like this,
struct point3d{
int x;
int y;
int z;
};
How can I create a hash value from this structure? Thanks
A lot depends on what you want to achieve and how much distribution you need.
Most non-cryptographic hash would be similar to :
int64_t Hash(const point3d & point){
int64_t start = 1234; //magic number
int64_t multiplier = 3467; //some other magic number
int64_t hash = start + point.x;
hash = hash*multiplier + point.y;
hash = hash * multiplier + point.z;
return hash;
}
Test this out on your data set by tuning start
and multiplier
.