Package com.actelion.research.util
Class BurtleHasher
- java.lang.Object
-
- com.actelion.research.util.BurtleHasher
-
public class BurtleHasher extends java.lang.Object
http://burtleburtle.net/bob/c/lookup3.c ------------------------------------------------------------------------------- lookup3.c, by Bob Jenkins, May 2006, Public Domain. These are functions for producing 32-bit hashes for hash table lookup. hashword(), hashlittle(), hashbig(), mix(), and final() are externally useful functions. Routines to test the hash are included if SELF_TEST is defined. You can use this free for any purpose. It has no warranty. You probably want to use hashlittle(). hashlittle() and hashbig() hash byte arrays. hashlittle() is is faster than hashbig() on little-endian machines. Intel and AMD are little-endian machines. If you want to find a hash of, say, exactly 7 integers, do a = i1; b = i2; c = i3; mix(a,b,c); a += i4; b += i5; c += i6; mix(a,b,c); a += i7; final(a,b,c); then use c as the hash value. If you have a variable length array of 4-byte integers to hash, use hashword(). If you have a byte array (like a character string), use hashlittle(). If you have several byte arrays, or a mix of things, see the comments above hashlittle(). -------------------------------------------------------------------------------
-
-
Constructor Summary
Constructors Constructor Description BurtleHasher()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
driver1()
static void
driver3()
static int
hashlittle(byte[] k, long initval)
static int
hashlittle(byte[] k, long initval, int size)
static int
hashlittle(int[] k, long initval)
MvK 10.02.2010static int
hashlittle(int[] k, long initval, int size)
static int
hashlittle(java.lang.String key, long initval)
static int
hashmask(int n)
static int
hashsize(long n)
static int
hashword(java.lang.String w, long initval)
static void
main(java.lang.String[] args)
static void
mix64(BurtleHasherABC abc)
static long
rot(long x, long k)
-
-
-
Method Detail
-
hashsize
public static int hashsize(long n)
-
hashmask
public static int hashmask(int n)
- Parameters:
n
- number of bits set in mask.- Returns:
-
rot
public static long rot(long x, long k)
-
mix64
public static void mix64(BurtleHasherABC abc)
-
hashword
public static int hashword(java.lang.String w, long initval)
-
hashlittle
public static int hashlittle(java.lang.String key, long initval)
-
hashlittle
public static int hashlittle(byte[] k, long initval)
-
hashlittle
public static int hashlittle(byte[] k, long initval, int size)
- Parameters:
k
-initval
-size
- the hash value will be calculated for k up to size fields.- Returns:
-
hashlittle
public static int hashlittle(int[] k, long initval)
MvK 10.02.2010- Parameters:
k
-initval
-- Returns:
-
hashlittle
public static int hashlittle(int[] k, long initval, int size)
- Parameters:
k
-initval
-size
- the hash value will be calculated for k up to size fields.- Returns:
-
driver1
public static void driver1()
-
driver3
public static void driver3()
-
main
public static void main(java.lang.String[] args)
-
-