public static long [ ] [ ] preprocessJenkins ( final BitVector bv , final long seed ) { final long length = bv . length ( ) ; final int wordLength = ( int ) ( length / ( Long . SIZE * 3 ) ) + 1 ; final long aa [ ] = new long [ wordLength ] , bb [ ] = new long [ wordLength ] , cc [ ] = new long [ wordLength ] ; long a , b , c , from = 0 ; if ( aa . length == 0 ) return new long [ 3 ] [ 0 ] ; int i = 0 ; /* Set up the internal state */ a = b = seed ; c = ARBITRARY_BITS ; aa [ i ] = a ; bb [ i ] = b ; cc [ i ] = c ; i ++ ; while ( length - from >= Long . SIZE * 3 ) { a += bv . getLong ( from , from + Long . SIZE ) ; b += bv . getLong ( from + Long . SIZE , from + 2 * Long . SIZE ) ; c += bv . getLong ( from + 2 * Long . SIZE , from + 3 * Long . SIZE ) ; a -= b ; a -= c ; a ^= ( c >>> 43 ) ; b -= c ; b -= a ; b ^= ( a << 9 ) ; c -= a ; c -= b ; c ^= ( b >>> 8 ) ; a -= b ; a -= c ; a ^= ( c >>> 38 ) ; b -= c ; b -= a ; b ^= ( a << 23 ) ; c -= a ; c -= b ; c ^= ( b >>> 5 ) ; a -= b ; a -= c ; a ^= ( c >>> 35 ) ; b -= c ; b -= a ; b ^= ( a << 49 ) ; c -= a ; c -= b ; c ^= ( b >>> 11 ) ; a -= b ; a -= c ; a ^= ( c >>> 12 ) ; b -= c ; b -= a ; b ^= ( a << 18 ) ; c -= a ; c -= b ; c ^= ( b >>> 22 ) ; from += 3 * Long . SIZE ; aa [ i ] = a ; bb [ i ] = b ; cc [ i ] = c ; i ++ ; } return new long [ ] [ ] { aa , bb , cc } ; }
Preprocesses a bit vector so that Jenkins 64 - bit hashing can be computed in constant time on all prefixes .