ivanshuba opened a new pull request, #227:
URL: https://github.com/apache/commons-geometry/pull/227

   This commit modifies the `hashCode()` method for `Vector2D` and the 
`Vector3D` classes in order to ensure unique values are generated for 
non-identical instances of vectors.
   
   The proposed approach for calculating the hash code value is the same that 
is used in JTS and HE_Mesh projects. And as quoted in JTS project, this 
approach was initially 'borrowed' from the Joshua Bloch book 'Effective Java' 
(1st ed, 2008).
   
   In the "Item 9: Always override hashCode when you override equals" he 
describes the recipe as follows:
   
   1. Store some constant nonzero value, say 17, in an int variable called 
`result`.
   2. For each significant field `f` in your object, do the following: a. 
Compute an int hash code `c` for the field:
         i   ...
         ii  ...
         iii If the field is a long, compute (int)(f^(f>>>32))
         iv  ...
         v   If the field is a double, compute Double.doublToLongBits(f),
             and then hash the resulting long as in step 2.a.iii
         vi  ...
         vii ...
      b. Combine the hash code `c` computed in step 2.a into `result` as
         follows:
           result = 31 * result + c


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to