From 345a9932ecb33331ab41264ea62c8ff9da714bc5 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 9 Mar 2023 01:35:41 -0500 Subject: [PATCH] [+] Integer hash function --- tngame-rs/src/utils.rs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tngame-rs/src/utils.rs diff --git a/tngame-rs/src/utils.rs b/tngame-rs/src/utils.rs new file mode 100644 index 0000000..55830e1 --- /dev/null +++ b/tngame-rs/src/utils.rs @@ -0,0 +1,8 @@ + +// Integer hashing +pub fn hash(mut x: u32) -> u32 { + x = ((x >> 16) ^ x).wrapping_mul(0x45d9f3b); + x = ((x >> 16) ^ x).wrapping_mul(0x45d9f3b); + x = (x >> 16) ^ x; + x +} \ No newline at end of file