Replaced Vector.hashCode with a more reliable method

This commit is contained in:
Dinnerbone 2011-02-19 23:11:56 +00:00
parent 3f971e42eb
commit e5db796188

View File

@ -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;
}
/**