public class GoldPointHash extends IPointHash.IntImpl
IPointHash
that multiplies each of the x, y, etc. components and the state by a different
constant for each (a "harmonious number" related to the golden ratio), sums them, and keeps only the upper bits.
This benefits from dot-product optimizations performed by recent JVMs (since at least Java 8). It finishes each hash
with an XLCG step to improve the upper bits, then it right-shifts the whole long so it fits in the desired output
range (such as 8 bits for hash256(int, int, int)
), casts it to int and returns that.
IntPointHash
, and has comparable quality, but
does require a lot of math on long values, and that can be quite slow on GWT. This should probably be used primarily
on desktop targets, and/or maybe mobile.IPointHash.IntImpl, IPointHash.LongImpl
Modifier and Type | Field and Description |
---|---|
static GoldPointHash |
INSTANCE |
state
Constructor and Description |
---|
GoldPointHash() |
GoldPointHash(int state) |
Modifier and Type | Method and Description |
---|---|
static int |
hash256(int x,
int y,
int s)
A 8-bit point hash that smashes x and y into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash256(int x,
int y,
int z,
int s)
A 8-bit point hash that smashes x, y, and z into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash256(int x,
int y,
int z,
int w,
int s)
A 8-bit point hash that smashes x, y, z, and w into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash256(int x,
int y,
int z,
int w,
int u,
int v,
int s)
A 8-bit point hash that smashes x, y, z, w, u, and v into s using XOR and multiplications by harmonious
numbers, then runs a simple unary hash on s and returns it.
|
static int |
hash32(int x,
int y,
int s)
A 5-bit point hash that smashes x and y into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash32(int x,
int y,
int z,
int s)
A 5-bit point hash that smashes x, y, and z into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash32(int x,
int y,
int z,
int w,
int s)
A 5-bit point hash that smashes x, y, z, and w into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash32(int x,
int y,
int z,
int w,
int u,
int v,
int s)
A 5-bit point hash that smashes x, y, z, w, u, and v into s using XOR and multiplications by harmonious
numbers, then runs a simple unary hash on s and returns it.
|
static int |
hash64(int x,
int y,
int s)
A 6-bit point hash that smashes x and y into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash64(int x,
int y,
int z,
int s)
A 6-bit point hash that smashes x, y, and z into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash64(int x,
int y,
int z,
int w,
int s)
A 6-bit point hash that smashes x, y, z, and w into s using XOR and multiplications by harmonious numbers,
then runs a simple unary hash on s and returns it.
|
static int |
hash64(int x,
int y,
int z,
int w,
int u,
int v,
int s)
A 6-bit point hash that smashes x, y, z, w, u, and v into s using XOR and multiplications by harmonious
numbers, then runs a simple unary hash on s and returns it.
|
static int |
hashAll(int x,
int y,
int s)
A 32-bit-result point hash that uses multiplication with long constants.
|
static int |
hashAll(int x,
int y,
int z,
int s)
A 32-bit-result point hash that uses multiplication with long constants.
|
static int |
hashAll(int x,
int y,
int z,
int w,
int s)
A 32-bit-result point hash that uses multiplication with long constants.
|
static int |
hashAll(int x,
int y,
int z,
int w,
int u,
int s)
A 32-bit-result point hash that uses multiplication with long constants.
|
static int |
hashAll(int x,
int y,
int z,
int w,
int u,
int v,
int s)
A 32-bit-result point hash that uses multiplication with long constants.
|
int |
hashWithState(int x,
int y,
int state) |
int |
hashWithState(int x,
int y,
int z,
int state) |
int |
hashWithState(int x,
int y,
int z,
int w,
int state) |
int |
hashWithState(int x,
int y,
int z,
int w,
int u,
int state) |
int |
hashWithState(int x,
int y,
int z,
int w,
int u,
int v,
int state) |
public static final GoldPointHash INSTANCE
public GoldPointHash()
public GoldPointHash(int state)
public int hashWithState(int x, int y, int state)
public int hashWithState(int x, int y, int z, int state)
public int hashWithState(int x, int y, int z, int w, int state)
public int hashWithState(int x, int y, int z, int w, int u, int state)
public int hashWithState(int x, int y, int z, int w, int u, int v, int state)
public static int hashAll(int x, int y, int s)
x
- x position, as an inty
- y position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hashAll(int x, int y, int z, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hashAll(int x, int y, int z, int w, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hashAll(int x, int y, int z, int w, int u, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hashAll(int x, int y, int z, int w, int u, int v, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an intv
- v position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash256(int x, int y, int s)
x
- x position, as an inty
- y position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash256(int x, int y, int z, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash256(int x, int y, int z, int w, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash256(int x, int y, int z, int w, int u, int v, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an intv
- v position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash64(int x, int y, int s)
x
- x position, as an inty
- y position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash64(int x, int y, int z, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash64(int x, int y, int z, int w, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash64(int x, int y, int z, int w, int u, int v, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an intv
- v position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash32(int x, int y, int s)
x
- x position, as an inty
- y position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash32(int x, int y, int z, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash32(int x, int y, int z, int w, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an ints
- any int, a seed to be able to produce many hashes for a given pointpublic static int hash32(int x, int y, int z, int w, int u, int v, int s)
x
- x position, as an inty
- y position, as an intz
- z position, as an intw
- w position, as an intu
- u position, as an intv
- v position, as an ints
- any int, a seed to be able to produce many hashes for a given pointCopyright © Eben Howard 2012–2022. All rights reserved.