public class JenkinsHash extends Object
Modifier and Type | Field and Description |
---|---|
(package private) long |
a |
(package private) long |
b |
(package private) long |
c |
private static long |
MAX_VALUE |
Constructor and Description |
---|
JenkinsHash() |
Modifier and Type | Method and Description |
---|---|
private long |
add(long val,
long add)
Do addition and turn into 4 bytes.
|
private long |
byteToLong(byte b)
Convert a byte into a long value without making it negative.
|
private long |
fourByteToLong(byte[] bytes,
int offset)
Convert 4 bytes from the buffer at offset into a long value.
|
long |
hash(byte[] buffer)
See hash(byte[] buffer, long initialValue)
|
long |
hash(byte[] buffer,
long initialValue)
Hash a variable-length key into a 32-bit value.
|
private void |
hashMix()
Mix up the values in the hash function.
|
private long |
leftShift(long val,
int shift)
Left shift val by shift bits.
|
private long |
subtract(long val,
long subtract)
Do subtraction and turn into 4 bytes.
|
private long |
xor(long val,
long xor)
Left shift val by shift bits and turn in 4 bytes.
|
private static final long MAX_VALUE
long a
long b
long c
private long byteToLong(byte b)
private long add(long val, long add)
private long subtract(long val, long subtract)
private long xor(long val, long xor)
private long leftShift(long val, int shift)
private long fourByteToLong(byte[] bytes, int offset)
private void hashMix()
public long hash(byte[] buffer, long initialValue)
buffer
- Byte array that we are hashing on.initialValue
- Initial value of the hash if we are continuing from
a previous run. 0 if none.public long hash(byte[] buffer)
buffer
- Byte array that we are hashing on.Copyright © 2012. All Rights Reserved.