First of all, I found an implementation of GetHashCode for a 3D integer vector, but I can't figure out if this is a good one or not (at least I'm not 100% sure):
public struct Vector3i
{
public int x;
public int y;
public int z;
public override int GetHashCode ()
{
return x.GetHashCode () ^ y.GetHashCode () << 2 ^ z.GetHashCode () >> 2;
}
}
From this, I would like to create a pair of 3D vectors (let's call them A and B) with a hashcode which is independent from the order of Vectors A and B. In other words I want the pair (A, B) to have the same hashcode than the pair (B, A). I thought of something like this:
public struct Vector3iPair
{
public Vector3i a;
public Vector3i b;
public override int GetHashCode ()
{
return a.GetHashCode () ^ b.GetHashCode ();
}
}
Do you think this would have the correct behavior?