How to implement GetHashCode for a pair of 3D vectors

This question already has an answer here:

  • What is the best algorithm for an overridden System.Object.GetHashCode? 17 answers

  • Please reference this answer for a correct implementation of the GetHashCode(), as it's suitable for your question as well.

    As for your second part of the question, it should work fine as the bitwise xor (^) is commutative, meaning you'll get same result regardless of order of operations.

    However, the question arises, are you just going to put your vectors into Hashmaps or do you have some different spatial hashing approach in mind?

    链接地址: http://www.djcxy.com/p/39764.html

    上一篇: 根据对象的某些属性创建唯一的哈希码

    下一篇: 如何为一对3D矢量实现GetHashCode