public final class HashMath
extends java.lang.Object
| Modifier and Type | Method | Description |
|---|---|---|
static int |
multiHashOrdered(int accumulatedHash,
int nextHash) |
A hash function which combines an accumulated hash with a next hash such that
f(f(k, b), a) \u2260\u2099 f(f(k, a), b). |
static int |
multiHashOrdered(int accumulatedHash,
int prime,
int nextHash) |
A hash function which combines an accumulated hash with a next hash such that
f(f(k, p2, b), p1, a) \u2260\u2099 f(f(k, p1, a), p2, b). |
static int |
multiHashUnordered(int accumulatedHash,
int nextHash) |
A hash function which combines an accumulated hash with a next hash such that
f(f(k, b), a) = f(f(k, a), b). |
static int |
multiHashUnordered(int accumulatedHash,
int prime,
int nextHash) |
A hash function which combines an accumulated hash with a next hash such that
f(f(k, p2, b), p1, a) = f(f(k, p1, a), p2, b). |
static int |
multiplyWrap(int a,
int b) |
Multiply two unsigned integers together.
|
static int |
roundToPowerOfTwo(int value) |
Round the given value up to the next positive power of two.
|
public static int roundToPowerOfTwo(int value)
value - the value (must not be negative and must be less than or equal to 2^31)public static int multiHashOrdered(int accumulatedHash,
int prime,
int nextHash)
f(f(k, p2, b), p1, a) \u2260\u2099 f(f(k, p1, a), p2, b).
This function is suitable for object chains whose order affects the overall equality of the hash code.
The exact algorithm is not specified and is therefore subject to change and should not be relied upon for hash codes that persist outside of the JVM process.
accumulatedHash - the accumulated hash code of the previous stageprime - a prime multipliernextHash - the hash code of the next single itempublic static int multiHashUnordered(int accumulatedHash,
int prime,
int nextHash)
f(f(k, p2, b), p1, a) = f(f(k, p1, a), p2, b).
This function is suitable for object chains whose order does not affect the overall equality of the hash code.
The exact algorithm is not specified and is therefore subject to change and should not be relied upon for hash codes that persist outside of the JVM process.
accumulatedHash - the accumulated hash code of the previous stageprime - a prime multipliernextHash - the hash code of the next single itempublic static int multiHashOrdered(int accumulatedHash,
int nextHash)
f(f(k, b), a) \u2260\u2099 f(f(k, a), b).
This function is suitable for object chains whose order affects the overall equality of the hash code.
The exact algorithm is not specified and is therefore subject to change and should not be relied upon for hash codes that persist outside of the JVM process.
accumulatedHash - the accumulated hash code of the previous stagenextHash - the hash code of the next single itempublic static int multiHashUnordered(int accumulatedHash,
int nextHash)
f(f(k, b), a) = f(f(k, a), b).
This function is suitable for object chains whose order does not affect the overall equality of the hash code.
The exact algorithm is not specified and is therefore subject to change and should not be relied upon for hash codes that persist outside of the JVM process.
accumulatedHash - the accumulated hash code of the previous stagenextHash - the hash code of the next single itempublic static int multiplyWrap(int a,
int b)
\u2a30 symbol to represent this operation, then a \u2a30 b = b \u2a30 a.
This operation is not associative, i.e. (a \u2a30 b) \u2a30 c \u2260\u2099 a \u2a30 (b \u2a30 c) (the symbol \u2260\u2099 meaning "not necessarily equal to"),
therefore this operation is suitable for ordered combinatorial hash functions.a - the first number to multiplyb - the second number to multiplyCopyright © 2018 JBoss, a division of Red Hat, Inc.