Replaced Vector.hashCode with a more reliable method
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
6203fc2652
commit
08fd2073ce
1 changed files with 6 additions and 5 deletions
|
@ -526,16 +526,17 @@ public class Vector implements Cloneable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this vector. Due to floating point errors, this
|
||||
* hash code should not be used in hash tables of any sort.
|
||||
* Returns a hash code for this vector
|
||||
*
|
||||
* @return hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ((int)Double.doubleToLongBits(x) >> 13) ^
|
||||
((int)Double.doubleToLongBits(y) >> 7) ^
|
||||
(int)Double.doubleToLongBits(z);
|
||||
int hash = 7;
|
||||
hash = 79 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
|
||||
hash = 79 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
|
||||
hash = 79 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32));
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue