Class LongPointHash

java.lang.Object
com.github.yellowstonegames.grid.IPointHash.LongImpl
com.github.yellowstonegames.grid.LongPointHash
All Implemented Interfaces:
IPointHash

public final class LongPointHash extends IPointHash.LongImpl
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 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
    Constructor
    Description
     
    LongPointHash(int state)
     
    LongPointHash(long state)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
     
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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.
    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)
     
    int
    hashWithState(int x, int y, int z, int w, int u, int v, int m, int state)
     

    Methods inherited from class IPointHash.LongImpl

    hash, hash, hash, hash, hash, setState, setState

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 long
      y - y position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      v - v position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      v - v position; any long
      m - m position; any long
      s - 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 long
      y - y position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      v - v position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      v - v position; any long
      m - m position; any long
      s - 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 long
      y - y position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      v - v position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      v - v position; any long
      m - m position; any long
      s - 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 long
      y - y position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      v - v position; any long
      s - 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 long
      y - y position; any long
      z - z position; any long
      w - w position; any long
      u - u position; any long
      v - v position; any long
      m - m position; any long
      s - the state; any long
      Returns:
      6-bit hash of the x,y,z,w,u,v,m point with the given state