public static long generate ( long hash , final CharSequence value ) { final long m = 0xc6a4a7935bd1e995 L ; final int r = 47 ; int strlen = value . length ( ) ; int length = 2 * strlen ; hash ^= length * m ; int len4 = strlen / 4 ; int offset = 0 ; for ( int i = 0 ; i < len4 ; i ++ ) { final int index = i * 4 + offset ; long k = ( value . charAt ( index + 0 ) | ( ( long ) value . charAt ( index + 1 ) << 16 ) | ( ( long ) value . charAt ( index + 2 ) << 32 ) | ( ( long ) value . charAt ( index + 3 ) << 48 ) ) ; k *= m ; k ^= k >>> r ; k *= m ; hash ^= k ; hash *= m ; } final int off = offset + ( strlen & ~ 0x3 ) ; switch ( strlen % 4 ) { case 3 : hash ^= ( long ) value . charAt ( off + 2 ) << 48 ; case 2 : hash ^= ( long ) value . charAt ( off + 1 ) << 32 ; case 1 : hash ^= ( long ) value . charAt ( off + 0 ) << 16 ; hash *= m ; } hash ^= hash >>> r ; hash *= m ; hash ^= hash >>> r ; return hash ; }
Calculates hash from a String using utf - 16 encoding