Class LongPointHash
java.lang.Object
com.github.yellowstonegames.grid.IPointHash.LongImpl
com.github.yellowstonegames.grid.LongPointHash
- All Implemented Interfaces:
IPointHash
A group of similar methods for getting hashes of points based on long coordinates in 2, 3, 4, 5, or 6 dimensions and
a long for state. This implementation has high enough quality to be useful as a source of random numbers based on
positions, as long as the number of points hashed isn't extreme (correlations may be detectable after some millions
or billions of points). You should consider
This implements
IntPointHash if your input and output types are usually int,
since it's even faster, but if your seed is usually a long then this is appropriate.
This implements
IPointHash and has a long it uses internally for state, exposed by getState().-
Nested Class Summary
Nested classes/interfaces inherited from interface IPointHash
IPointHash.IntImpl, IPointHash.LongImpl -
Field Summary
Fields inherited from class IPointHash.LongImpl
state -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetState()static inthash256(long x, long y, long s) Gets an 8-bit point hash of a 2D point (x and y are both longs) and a state/seed as a long.static inthash256(long x, long y, long z, long s) Gets an 8-bit point hash of a 3D point (x, y, and z are all longs) and a state/seed as a long.static inthash256(long x, long y, long z, long w, long s) Gets an 8-bit point hash of a 4D point (x, y, z, and w are all longs) and a state/seed as a long.static inthash256(long x, long y, long z, long w, long u, long s) Gets an 8-bit point hash of a 5D point (x, y, z, w, and u are all longs) and a state/seed as a long.static inthash256(long x, long y, long z, long w, long u, long v, long s) Gets an 8-bit point hash of a 6D point (x, y, z, w, u, and v are all longs) and a state/seed as a long.static inthash256(long x, long y, long z, long w, long u, long v, long m, long s) Gets an 8-bit point hash of a 7D point (x, y, z, w, u, v, and m are all longs) and a state/seed as a long.static inthash32(long x, long y, long s) Gets a 5-bit point hash of a 2D point (x and y are both longs) and a state/seed as a long.static inthash32(long x, long y, long z, long s) Gets a 5-bit point hash of a 3D point (x, y, and z are all longs) and a state/seed as a long.static inthash32(long x, long y, long z, long w, long s) Gets a 5-bit point hash of a 4D point (x, y, z, and w are all longs) and a state/seed as a long.static inthash32(long x, long y, long z, long w, long u, long s) Gets a 5-bit point hash of a 5D point (x, y, z, w, and u are all longs) and a state/seed as a long.static inthash32(long x, long y, long z, long w, long u, long v, long s) Gets a 5-bit point hash of a 6D point (x, y, z, w, u, and v are all longs) and a state/seed as a long.static inthash32(long x, long y, long z, long w, long u, long v, long m, long s) Gets a 5-bit point hash of a 7D point (x, y, z, w, u, v, and m are all longs) and a state/seed as a long.static inthash64(long x, long y, long s) Gets a 6-bit point hash of a 2D point (x and y are both longs) and a state/seed as a long.static inthash64(long x, long y, long z, long s) Gets a 6-bit point hash of a 3D point (x, y, and z are all longs) and a state/seed as a long.static inthash64(long x, long y, long z, long w, long s) Gets a 6-bit point hash of a 4D point (x, y, z, and w are all longs) and a state/seed as a long.static inthash64(long x, long y, long z, long w, long u, long s) Gets a 6-bit point hash of a 5D point (x, y, z, w, and u are all longs) and a state/seed as a long.static inthash64(long x, long y, long z, long w, long u, long v, long s) Gets a 6-bit point hash of a 6D point (x, y, z, w, u, and v are all longs) and a state/seed as a long.static inthash64(long x, long y, long z, long w, long u, long v, long m, long s) Gets a 6-bit point hash of a 7D point (x, y, z, w, u, v, and m are all longs) and a state/seed as a long.static longhashAll(long x, long y, long s) Gets a 64-bit point hash of a 2D point (x and y are both longs) and a state/seed as a long.static longhashAll(long x, long y, long z, long s) Gets a 64-bit point hash of a 3D point (x, y, and z are all longs) and a state/seed as a long.static longhashAll(long x, long y, long z, long w, long s) Gets a 64-bit point hash of a 4D point (x, y, z, and w are all longs) and a state/seed as a long.static longhashAll(long x, long y, long z, long w, long u, long s) Gets a 64-bit point hash of a 5D point (x, y, z, w, and u are all longs) and a state/seed as a long.static longhashAll(long x, long y, long z, long w, long u, long v, long s) Gets a 64-bit point hash of a 6D point (x, y, z, w, u, and v are all longs) and a state/seed as a long.static longhashAll(long x, long y, long z, long w, long u, long v, long m, long s) Gets a 64-bit point hash of a 7D point (x, y, z, w, u, v, and m are all longs) and a state/seed as a long.inthashWithState(int x, int y, int state) inthashWithState(int x, int y, int z, int state) inthashWithState(int x, int y, int z, int w, int state) inthashWithState(int x, int y, int z, int w, int u, int state) inthashWithState(int x, int y, int z, int w, int u, int v, int state) inthashWithState(int x, int y, int z, int w, int u, int v, int m, int state)
-
Constructor Details
-
LongPointHash
public LongPointHash() -
LongPointHash
public LongPointHash(int state) -
LongPointHash
public LongPointHash(long state)
-
-
Method Details
-
hashWithState
public int hashWithState(int x, int y, int state) -
hashWithState
public int hashWithState(int x, int y, int z, int state) -
hashWithState
public int hashWithState(int x, int y, int z, int w, int state) -
hashWithState
public int hashWithState(int x, int y, int z, int w, int u, int state) -
hashWithState
public int hashWithState(int x, int y, int z, int w, int u, int v, int state) -
hashWithState
public int hashWithState(int x, int y, int z, int w, int u, int v, int m, int state) -
getState
public long getState() -
hashAll
public static long hashAll(long x, long y, long s) Gets a 64-bit point hash of a 2D point (x and y are both longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longs- the state/seed; any long- Returns:
- 64-bit hash of the x,y point with the given state
-
hashAll
public static long hashAll(long x, long y, long z, long s) Gets a 64-bit point hash of a 3D point (x, y, and z are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longs- the state/seed; any long- Returns:
- 64-bit hash of the x,y,z point with the given state
-
hashAll
public static long hashAll(long x, long y, long z, long w, long s) Gets a 64-bit point hash of a 4D point (x, y, z, and w are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longs- the state; any long- Returns:
- 64-bit hash of the x,y,z,w point with the given state
-
hashAll
public static long hashAll(long x, long y, long z, long w, long u, long s) Gets a 64-bit point hash of a 5D point (x, y, z, w, and u are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longs- the state; any long- Returns:
- 64-bit hash of the x,y,z,w,u point with the given state
-
hashAll
public static long hashAll(long x, long y, long z, long w, long u, long v, long s) Gets a 64-bit point hash of a 6D point (x, y, z, w, u, and v are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longv- v position; any longs- the state; any long- Returns:
- 64-bit hash of the x,y,z,w,u,v point with the given state
-
hashAll
public static long hashAll(long x, long y, long z, long w, long u, long v, long m, long s) Gets a 64-bit point hash of a 7D point (x, y, z, w, u, v, and m are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longv- v position; any longm- m position; any longs- the state; any long- Returns:
- 64-bit hash of the x,y,z,w,u,v,m point with the given state
-
hash256
public static int hash256(long x, long y, long s) Gets an 8-bit point hash of a 2D point (x and y are both longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longs- the state/seed; any long- Returns:
- 8-bit hash of the x,y point with the given state
-
hash256
public static int hash256(long x, long y, long z, long s) Gets an 8-bit point hash of a 3D point (x, y, and z are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longs- the state/seed; any long- Returns:
- 8-bit hash of the x,y,z point with the given state
-
hash256
public static int hash256(long x, long y, long z, long w, long s) Gets an 8-bit point hash of a 4D point (x, y, z, and w are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longs- the state; any long- Returns:
- 8-bit hash of the x,y,z,w point with the given state
-
hash256
public static int hash256(long x, long y, long z, long w, long u, long s) Gets an 8-bit point hash of a 5D point (x, y, z, w, and u are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longs- the state; any long- Returns:
- 8-bit hash of the x,y,z,w,u point with the given state
-
hash256
public static int hash256(long x, long y, long z, long w, long u, long v, long s) Gets an 8-bit point hash of a 6D point (x, y, z, w, u, and v are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longv- v position; any longs- the state; any long- Returns:
- 8-bit hash of the x,y,z,w,u,v point with the given state
-
hash256
public static int hash256(long x, long y, long z, long w, long u, long v, long m, long s) Gets an 8-bit point hash of a 7D point (x, y, z, w, u, v, and m are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longv- v position; any longm- m position; any longs- the state; any long- Returns:
- 8-bit hash of the x,y,z,w,u,v,m point with the given state
-
hash32
public static int hash32(long x, long y, long s) Gets a 5-bit point hash of a 2D point (x and y are both longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longs- the state/seed; any long- Returns:
- 5-bit hash of the x,y point with the given state
-
hash32
public static int hash32(long x, long y, long z, long s) Gets a 5-bit point hash of a 3D point (x, y, and z are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longs- the state/seed; any long- Returns:
- 5-bit hash of the x,y,z point with the given state
-
hash32
public static int hash32(long x, long y, long z, long w, long s) Gets a 5-bit point hash of a 4D point (x, y, z, and w are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longs- the state; any long- Returns:
- 5-bit hash of the x,y,z,w point with the given state
-
hash32
public static int hash32(long x, long y, long z, long w, long u, long s) Gets a 5-bit point hash of a 5D point (x, y, z, w, and u are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longs- the state; any long- Returns:
- 5-bit hash of the x,y,z,w,u point with the given state
-
hash32
public static int hash32(long x, long y, long z, long w, long u, long v, long s) Gets a 5-bit point hash of a 6D point (x, y, z, w, u, and v are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longv- v position; any longs- the state; any long- Returns:
- 5-bit hash of the x,y,z,w,u,v point with the given state
-
hash32
public static int hash32(long x, long y, long z, long w, long u, long v, long m, long s) Gets a 5-bit point hash of a 7D point (x, y, z, w, u, v, and m are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longv- v position; any longm- m position; any longs- the state; any long- Returns:
- 5-bit hash of the x,y,z,w,u,v,m point with the given state
-
hash64
public static int hash64(long x, long y, long s) Gets a 6-bit point hash of a 2D point (x and y are both longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longs- the state/seed; any long- Returns:
- 6-bit hash of the x,y point with the given state
-
hash64
public static int hash64(long x, long y, long z, long s) Gets a 6-bit point hash of a 3D point (x, y, and z are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longs- the state/seed; any long- Returns:
- 6-bit hash of the x,y,z point with the given state
-
hash64
public static int hash64(long x, long y, long z, long w, long s) Gets a 6-bit point hash of a 4D point (x, y, z, and w are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longs- the state; any long- Returns:
- 6-bit hash of the x,y,z,w point with the given state
-
hash64
public static int hash64(long x, long y, long z, long w, long u, long s) Gets a 6-bit point hash of a 5D point (x, y, z, w, and u are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longs- the state; any long- Returns:
- 6-bit hash of the x,y,z,w,u point with the given state
-
hash64
public static int hash64(long x, long y, long z, long w, long u, long v, long s) Gets a 6-bit point hash of a 6D point (x, y, z, w, u, and v are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longv- v position; any longs- the state; any long- Returns:
- 6-bit hash of the x,y,z,w,u,v point with the given state
-
hash64
public static int hash64(long x, long y, long z, long w, long u, long v, long m, long s) Gets a 6-bit point hash of a 7D point (x, y, z, w, u, v, and m are all longs) and a state/seed as a long. This point hash is fast and very good at randomizing its bits when any argument changes even slightly.- Parameters:
x- x position; any longy- y position; any longz- z position; any longw- w position; any longu- u position; any longv- v position; any longm- m position; any longs- the state; any long- Returns:
- 6-bit hash of the x,y,z,w,u,v,m point with the given state
-