Skip to content

Use static hashCode() methods #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Use static hashCode() methods #353

wants to merge 1 commit into from

Conversation

jmr
Copy link

@jmr jmr commented Jun 4, 2025

Java 8 added static hashCode() methods like Double.hashCode(double).

https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#hashCode-double-

These are equivalent to what HashCommon.double2int(double) claims to do

https://javadoc.io/doc/it.unimi.dsi/fastutil/latest/it/unimi/dsi/fastutil/HashCommon.html#double2int(double)

but double2int() uses Double.doubleToRawLongBits(), whereas Double.HashCode() uses Double.doubleToLongBits(). Therefore, also update KEY2INTHASH() and KEY2LONGHASH() to use doubleToLongBits().

Since HashCommon is a public class, I didn't delete the old HashCommon.double2int(), float2int(), and long2int() functions.

Java 8 added static hashCode() methods like Double.hashCode(double).

https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#hashCode-double-

These are equivalent to what HashCommon.double2int(double) claims to do

https://javadoc.io/doc/it.unimi.dsi/fastutil/latest/it/unimi/dsi/fastutil/HashCommon.html#double2int(double)

but double2int() uses Double.doubleToRawLongBits(), whereas
Double.HashCode() uses Double.doubleToLongBits().  Therefore, also
update KEY2INTHASH() and KEY2LONGHASH() to use doubleToLongBits().

Since HashCommon is a public class, I didn't delete the old
HashCommon.double2int(), float2int(), and long2int() functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant