1 package org.simantics.scl.compiler.internal.types;
4 * Utils for computing 32-bit Murmur3 hash function
6 public class HashCodeUtils {
8 private static final int C1 = 0xcc9e2d51;
9 private static final int C2 = 0x1b873593;
10 private static final int R1 = 15;
11 private static final int R2 = 13;
12 private static final int M = 5;
13 private static final int N = 0xe6546b64;
15 public static final int SEED = 0;
17 public static int update(int hash, int value) {
19 value = Integer.rotateLeft(value, R1);
23 return Integer.rotateLeft(hash, R2) * M + N;
26 public static int preprocessValue(int value) {
28 value = Integer.rotateLeft(value, R1);
33 public static int updateWithPreprocessedValue(int hash, int preprocessedValue) {
34 hash ^= preprocessedValue;
35 return Integer.rotateLeft(hash, R2) * M + N;
38 public static int finalize(int hash) {