Here you can find the source of hashJava32(byte[] byteList)
Parameter | Description |
---|---|
byteList | The bytes to hash |
public static int hashJava32(byte[] byteList)
//package com.java2s; /**/*from ww w . j av a2 s . co m*/ * Copyright 2014 Expedia, Inc. All rights reserved. * EXPEDIA PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { private static final int BITMASK_POSITIVE_32 = ~0x80000000; /** * This is a copy of the hash function in JDK 1.6 to ensure it does not change. * MultiCache will lose data if the function changes. * * @param byteList The bytes to hash * @return A 32 bits hash */ public static int hashJava32(byte[] byteList) { if (byteList == null) { return 0; } long hash = 1; for (int i = 0; i < byteList.length; i++) { byte element = byteList[i]; hash = 31 * hash + element; } return (int) hash & BITMASK_POSITIVE_32; } }