|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.util.HashUtil
public final class HashUtil
Provides various static utility methods for dealing with hashes.
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Nested Class Summary | |
---|---|
static class |
HashUtil.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Field Summary | |
---|---|
private static int |
prime1
A 31-bit prime number. |
private static int |
prime2
A 31-bit prime number. |
Constructor Summary | |
---|---|
private |
HashUtil()
This private constructor suppresses the default (public) constructor, ensuring non-instantiability. |
Method Summary | |
---|---|
static int |
enhance(int h)
Attempts to return a very high quality hash function on h (i.e. one that is uniformly distributed among all possible int values, . |
static int |
enhanceFallback1(int h)
Returns a quick to compute hash of the input h. |
private static int |
enhanceFallback2(int h)
Returns a quick to compute hash of the input h. |
private static int |
enhanceFallback3(int h)
Returns a quick to compute hash of the input h. |
private static int |
enhanceFallback4(int h)
|
static int |
hash(double d)
Returns a high quality hash for the double arg d. |
static int |
hash(long l)
Returns a high quality hash for the long arg l. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int prime1
private static final int prime2
Constructor Detail |
---|
private HashUtil()
Method Detail |
---|
public static int enhance(int h)
This method is needed if h is initially a poor quality hash.
Prime example: Integer.hashCode
simply returns the int value, which is an extremely bad hash.
The implementation here first attempts to use the extremely strong SHA-1 hash algorithm on h.
If any problem occurs (e.g. the algorithm is unavailable), enhanceFallback4
(h) is returned.
public static int enhanceFallback1(int h)
enhance
as a fallback algorithm in the event of a problem.
private static int enhanceFallback2(int h)
enhance
as a fallback algorithm in the event of a problem.
private static int enhanceFallback3(int h)
enhance
as a fallback algorithm in the event of a problem.
private static int enhanceFallback4(int h)
public static int hash(double d)
public static int hash(long l)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |