Class KnownSizePointHash
java.lang.Object
com.github.yellowstonegames.grid.IPointHash.IntImpl
com.github.yellowstonegames.grid.KnownSizePointHash
- All Implemented Interfaces:
IPointHash
A very simple point hash meant only for fixed-size grids, and only for when the hash must be unique but does
not need to be randomized. If a hashed collection such as a Map has sufficient capacity to hold all items on
a grid without resizing, then this should never collide when only entering the items on that grid. If any of
the methods that need more than two dimensions of input are called, this delegates to
Based heavily on GoRogue/SadConsole/TheSadRogue.Primitives and its KnownSizeHasher.
IntPointHash.
Based heavily on GoRogue/SadConsole/TheSadRogue.Primitives and its KnownSizeHasher.
-
Nested Class Summary
Nested classes/interfaces inherited from interface IPointHash
IPointHash.IntImpl, IPointHash.LongImpl -
Field Summary
FieldsFields inherited from class IPointHash.IntImpl
state -
Constructor Summary
ConstructorsConstructorDescriptionCreates a KnownSizePointHash with a grid width of 80.KnownSizePointHash(int width) Creates a KnownSizePointHash with the specified grid width; the grid height doesn't matter.KnownSizePointHash(int state, int width) Creates a KnownSizePointHash with the specified state and grid width; the grid height doesn't matter. -
Method Summary
Modifier and TypeMethodDescriptioninthashWithState(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)
-
Field Details
-
width
public final int width
-
-
Constructor Details
-
KnownSizePointHash
public KnownSizePointHash()Creates a KnownSizePointHash with a grid width of 80. -
KnownSizePointHash
public KnownSizePointHash(int width) Creates a KnownSizePointHash with the specified grid width; the grid height doesn't matter.- Parameters:
width- how many cells wide the known grid is
-
KnownSizePointHash
public KnownSizePointHash(int state, int width) Creates a KnownSizePointHash with the specified state and grid width; the grid height doesn't matter.- Parameters:
state- the state of the point hash, which has minimal effect on the result (it is XORed in)width- how many cells wide the known grid is
-
-
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)
-