Here you can find the source of hashCode64(String s)
Parameter | Description |
---|---|
s | - the string to hash |
public static long hashCode64(String s)
//package com.java2s; /**/*from w w w . j a va 2 s . co m*/ * Syncnapsis Framework - Copyright (c) 2012-2014 ultimate * * This program is free software; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software Foundation; either version * 3 of the License, or any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MECHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Plublic License along with this program; * if not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * 64-bit variant of {@link String#hashCode()}<br> * * @see http://stackoverflow.com/a/1660613 * @param s - the string to hash * @return the 64-bit hash code */ public static long hashCode64(String s) { long h = 1125899906842597L; // prime int len = s.length(); for (int i = 0; i < len; i++) { h = 31 * h + s.charAt(i); } return h; } }