Java Hash String hashCode64(String s)

Here you can find the source of hashCode64(String s)

Description

64-bit variant of String#hashCode()

License

Open Source License

Parameter

Parameter Description
s - the string to hash

Return

the 64-bit hash code

Declaration

public static long hashCode64(String s) 

Method Source Code

//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;
    }
}

Related

  1. hashCode(String s)
  2. hashCode(String sIn)
  3. hashCode(String str)
  4. hashCode1(String str)
  5. hashCode2(String str)
  6. hashCode64(String s)
  7. hashCodeIgnoreCase(String a)
  8. hashCodeOfStringArray(String[] stringArray)
  9. hashCodeToString(byte[] hash)