public class GridBase
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.Hashtable |
grid |
Constructor and Description |
---|
GridBase() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
get(int x,
int y)
Get the object from cell (X,Y)
|
int |
getDimensionX()
Gets the current max grid dimension in x direction.
|
int |
getDimensionY()
Gets the current max grid dimension in y direction.
|
java.util.Hashtable |
getGrid() |
Pair<java.lang.Integer,java.lang.Integer> |
getGridPosition(java.lang.Object obj)
Returns the grid position of the passed object as Pair(x, y) or null, if the object is not in the grid
|
java.lang.Object |
remove(int x,
int y)
Removes any element at the specified position.
|
java.lang.Object |
set(int x,
int y,
java.lang.Object obj)
Set an object into cell (X,Y)
|
void |
setGrid(java.util.Hashtable grid) |
java.lang.String |
toString()
Writes the grid to a string.
|
public java.lang.Object set(int x, int y, java.lang.Object obj) throws java.lang.IndexOutOfBoundsException
x
- 0-based index first dimensiony
- 0-based index second dimensionobj
- Object to store at (x,y)java.lang.IndexOutOfBoundsException
public java.lang.Object get(int x, int y) throws java.lang.IndexOutOfBoundsException
x
- 0-based index first dimensiony
- 0-based index second dimensionjava.lang.IndexOutOfBoundsException
public int getDimensionX()
public int getDimensionY()
public java.lang.Object remove(int x, int y)
public java.util.Hashtable getGrid()
public void setGrid(java.util.Hashtable grid)
grid
- The grid to set.public Pair<java.lang.Integer,java.lang.Integer> getGridPosition(java.lang.Object obj)
public java.lang.String toString()
toString
in class java.lang.Object