Package squidpony.squidmath
Class PointHash
java.lang.Object
squidpony.squidmath.IPointHash.LongImpl
squidpony.squidmath.PointHash
- All Implemented Interfaces:
IPointHash
public final class PointHash extends IPointHash.LongImpl
A group of similar methods for getting hashes of points based on long coordinates in 2, 3, 4, or 6 dimensions and
a long for state. Internally, the methods here are based on a simplified version of Hive from
This implements
CrossHash
;
this version does not include the somewhat-involved finalization step. Omitting finalization helps this class be
somewhat faster, but also makes it so it doesn't avalanche very well. Avalanche refers to the property of a hash
where one changed bit in the input(s) or state has a chance to change any of the output's bits, and should
usually change about 50% of them. You can call avalanche(long)
on the result of a hashAll() call to put
the finalization step back. This has rather good quality when avalanche(long)
is used, but most usage
will not be able to discern a difference between the quality of this (with or without avalanche) and the quality of
HastyPointHash
, where HastyPointHash is a fair amount faster. If your state and input are ints anyway,
consider IntPointHash
, since it's faster than the long-based hashes and still has perfectly fine quality.
This implements
IPointHash
and has a long it uses internally for state, exposed by getState()
.-
Nested Class Summary
Nested classes/interfaces inherited from interface squidpony.squidmath.IPointHash
IPointHash.IntImpl, IPointHash.LongImpl
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PointHash()
-
Method Summary
Modifier and Type Method Description static long
avalanche(long state)
If it's important for some usage that one bit of change in any parameters cause roughly 50% of all bits in the result to change, then you can call this on the output of any hashAll() overload to improve the bit avalanche qualities.long
getState()
static int
hash256(long x, long y, long state)
static int
hash256(long x, long y, long z, long state)
static int
hash256(long x, long y, long z, long w, long state)
static int
hash256(long x, long y, long z, long w, long u, long v, long state)
static int
hash32(long x, long y, long state)
static int
hash32(long x, long y, long z, long state)
static int
hash32(long x, long y, long z, long w, long state)
static int
hash32(long x, long y, long z, long w, long u, long v, long state)
static int
hash64(long x, long y, long state)
static int
hash64(long x, long y, long z, long state)
static int
hash64(long x, long y, long z, long w, long state)
static int
hash64(long x, long y, long z, long w, long u, long v, long state)
static long
hashAll(long x, long y, long state)
static long
hashAll(long x, long y, long z, long state)
static long
hashAll(long x, long y, long z, long w, long state)
static long
hashAll(long x, long y, long z, long w, long u, long v, long state)
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 v, int state)
-
Constructor Details
-
Method Details
-
hashWithState
-
hashWithState
-
hashWithState
-
hashWithState
-
getState
-
avalanche
If it's important for some usage that one bit of change in any parameters cause roughly 50% of all bits in the result to change, then you can call this on the output of any hashAll() overload to improve the bit avalanche qualities.- Parameters:
state
- the output of hashAll() in this class- Returns:
- a significantly-mixed-around long obtained from state
-
hashAll
- Parameters:
x
-y
-state
-- Returns:
- 64-bit hash of the x,y point with the given state
-
hashAll
- Parameters:
x
-y
-z
-state
-- Returns:
- 64-bit hash of the x,y,z point with the given state
-
hashAll
- Parameters:
x
-y
-z
-w
-state
-- Returns:
- 64-bit hash of the x,y,z,w point with the given state
-
hashAll
- Parameters:
x
-y
-z
-w
-u
-v
-state
-- Returns:
- 64-bit hash of the x,y,z,w,u,v point with the given state
-
hash256
- Parameters:
x
-y
-state
-- Returns:
- 8-bit hash of the x,y point with the given state
-
hash256
- Parameters:
x
-y
-z
-state
-- Returns:
- 8-bit hash of the x,y,z point with the given state
-
hash256
- Parameters:
x
-y
-z
-w
-state
-- Returns:
- 8-bit hash of the x,y,z,w point with the given state
-
hash256
- Parameters:
x
-y
-z
-w
-u
-v
-state
-- Returns:
- 8-bit hash of the x,y,z,w,u,v point with the given state
-
hash32
- Parameters:
x
-y
-state
-- Returns:
- 5-bit hash of the x,y point with the given state
-
hash32
- Parameters:
x
-y
-z
-state
-- Returns:
- 5-bit hash of the x,y,z point with the given state
-
hash32
- Parameters:
x
-y
-z
-w
-state
-- Returns:
- 5-bit hash of the x,y,z,w point with the given state
-
hash32
- Parameters:
x
-y
-z
-w
-u
-v
-state
-- Returns:
- 5-bit hash of the x,y,z,w,u,v point with the given state
-
hash64
- Parameters:
x
-y
-state
-- Returns:
- 6-bit hash of the x,y point with the given state
-
hash64
- Parameters:
x
-y
-z
-state
-- Returns:
- 6-bit hash of the x,y,z point with the given state
-
hash64
- Parameters:
x
-y
-z
-w
-state
-- Returns:
- 6-bit hash of the x,y,z,w point with the given state
-
hash64
- Parameters:
x
-y
-z
-w
-u
-v
-state
-- Returns:
- 6-bit hash of the x,y,z,w,u,v point with the given state
-