|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.jagrlib.HashFunction
public final class HashFunction
General purpose hash function algorithms library. Original author: Arash Partow (2002), http://www.partow.net/ Adopted by: Josef Pelikan (2006). Copyright notice: Common Public License (http://www.opensource.org/licenses/cpl.php).
Nested Class Summary | |
---|---|
static class |
HashFunction.HashType
Implemented hash-functions. |
Field Summary | |
---|---|
protected byte[] |
byteArray
|
protected int |
endIndex
Points after the data segment to be processed. |
protected char[] |
charArray
|
protected int |
index
Index to actually processed array. |
protected int[] |
intArray
|
protected long[] |
longArray
|
protected long |
param
Hash-function parameter. |
protected int |
permutation
Permutation ordinal number (for coordinate hashing). |
protected short[] |
shortArray
|
protected short[] |
staticArray
|
protected java.lang.String |
string
Hash data: String. |
protected HashFunction.HashType |
type
Current hash-function type. |
Constructor Summary | |
---|---|
HashFunction()
|
|
HashFunction(HashFunction.HashType type)
|
|
HashFunction(HashFunction.HashType type,
long parameter)
|
Method Summary | |
---|---|
protected long |
APHash()
An algorithm produced by original author of this library: Arash Partow. |
protected long |
BKDRHash()
This hash function comes from Brian Kernighan and Dennis Ritchie's book "The C Programming Language". |
protected long |
DEKHash()
An algorithm proposed by Donald E. |
protected void |
distribute(int x)
Distributes integer value (32-bit) into two staticArray items. |
protected void |
distribute(long x)
Distributes long value (64-bit) into four staticArray items. |
protected long |
DJBHash()
An algorithm produced by Professor Daniel J. |
protected long |
ELFHash()
Similar to the PJW Hash function, but tweaked for 32-bit processors. |
protected void |
finishDistribution()
Finish staticArray distribution. |
protected long |
hash()
Internal hashing function (switches between the implementations). |
long |
hash(byte[] a)
Hashing the whole byte-array. |
long |
hash(byte[] a,
int from,
int to)
Hashing the segment from byte-array. |
long |
hash(double x,
double y)
Hashing double coordinate tuple. |
long |
hash(double x,
double y,
double z)
Hashing double coordinate triple. |
long |
hash(float x,
float y)
Hashing float coordinate tuple. |
long |
hash(float x,
float y,
float z)
Hashing float coordinate triple. |
long |
hash(char[] a)
Hashing the whole char-array. |
long |
hash(char[] a,
int from,
int to)
Hashing the segment from char-array. |
long |
hash(int[] a)
Hashing the whole int-array. |
long |
hash(int[] a,
int from,
int to)
Hashing the segment from int-array. |
long |
hash(int x,
int y)
Hashing integer coordinate tuple. |
long |
hash(int x,
int y,
int z)
Hashing integer coordinate triple. |
long |
hash(long[] a)
Hashing the whole long-array. |
long |
hash(long[] a,
int from,
int to)
Hashing the segment from long-array. |
long |
hash(short[] a)
Hashing the whole short-array. |
long |
hash(short[] a,
int from,
int to)
Hashing the segment from short-array. |
long |
hash(java.lang.String s)
Hashing the whole string. |
long |
hash(java.lang.String s,
int from,
int to)
Hashing the substring. |
protected void |
initDistribution()
Initialize staticArray distribution. |
protected long |
JSHash()
A bitwise hash function written by Justin Sobel. |
protected long |
LCGHash()
LCG-based hash function (LCG is from "Numerical Recipes in C"). |
long |
maxHash()
Hash-function returns values: 0 to maxHash()-1. |
protected int |
next()
Returns the next item (char, number). |
protected void |
permutate()
Permutates the staticArray[ 0 .. endIndex-1 ] by permutation order "permutation". |
protected long |
PJWHash()
This hash algorithm is based on work by Peter J. |
protected long |
RSHash()
A simple hash function from Robert Sedgwicks Algorithms in C book. |
protected long |
SDBMHash()
This is the algorithm of choice which is used in the open source SDBM project. |
long |
setParam(long parameter)
|
int |
setPerm(int perm)
|
void |
setType(HashFunction.HashType type)
|
void |
setVariation(int var)
Sets hash-function variation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected HashFunction.HashType type
protected long param
protected int permutation
protected int index
protected int endIndex
protected java.lang.String string
protected byte[] byteArray
protected short[] shortArray
protected char[] charArray
protected int[] intArray
protected long[] longArray
protected short[] staticArray
Constructor Detail |
---|
public HashFunction()
public HashFunction(HashFunction.HashType type)
public HashFunction(HashFunction.HashType type, long parameter)
Method Detail |
---|
protected final void initDistribution()
protected final void distribute(int x)
protected final void distribute(long x)
protected final void finishDistribution()
protected final int next()
protected final long hash()
protected final void permutate()
public final void setType(HashFunction.HashType type)
public final long setParam(long parameter)
public final int setPerm(int perm)
public final void setVariation(int var)
var
- Variation ordinal number (0, 1, ...).public final long maxHash()
public final long hash(java.lang.String s)
public final long hash(java.lang.String s, int from, int to)
public final long hash(byte[] a)
public final long hash(byte[] a, int from, int to)
public final long hash(short[] a)
public final long hash(short[] a, int from, int to)
public final long hash(char[] a)
public final long hash(char[] a, int from, int to)
public final long hash(int[] a)
public final long hash(int[] a, int from, int to)
public final long hash(long[] a)
public final long hash(long[] a, int from, int to)
public final long hash(int x, int y)
public final long hash(int x, int y, int z)
public final long hash(float x, float y)
public final long hash(float x, float y, float z)
public final long hash(double x, double y)
public final long hash(double x, double y, double z)
protected final long LCGHash()
protected final long RSHash()
protected final long JSHash()
protected final long PJWHash()
protected final long ELFHash()
protected final long BKDRHash()
protected final long SDBMHash()
protected final long DJBHash()
protected final long DEKHash()
protected final long APHash()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |