public final class LocationGrid extends Object implements Iterable<Location>
LocationLists.
Internally, the grid is backed by a Guava ArrayTable.
| Modifier and Type | Class and Description |
|---|---|
static class |
LocationGrid.Builder
A single-use builder of
LocationGrids. |
| Modifier and Type | Method and Description |
|---|---|
Bounds |
bounds()
Lazily compute the bounds of the
Locations in this grid. |
static LocationGrid.Builder |
builder(int rows,
int columns)
Return a new builder.
|
LocationList |
column(int index)
Return the column at index.
|
int |
columns()
Return the number of columns in this grid.
|
LocationList |
firstColumn()
Return the first column.
|
LocationList |
firstRow()
Return the first row.
|
Iterator<Location> |
iterator() |
LocationList |
lastColumn()
Return the last column.
|
LocationList |
lastRow()
Return the last row.
|
static void |
main(String[] args) |
LocationGrid |
parent()
Return the parent grid.
|
LocationList |
row(int index)
Return the row at index.
|
int |
rows()
Return the number of rows in this grid.
|
int |
size()
Return the number of
Locations in this grid. |
String |
toString() |
LocationGrid |
window(int rowStart,
int rowWidth,
int columnStart,
int columnWidth)
Return a new grid that is a window into this one.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic int size()
Locations in this grid.public int rows()
public LocationList row(int index)
index - of the row to retrieveIndexOutOfBoundsException - if index < 0 || index >= rows()public LocationList firstRow()
public LocationList lastRow()
public int columns()
public LocationList column(int index)
index - of the column to retrieveIndexOutOfBoundsException - if
index < 0 || index >= columns()public LocationList firstColumn()
public LocationList lastColumn()
public LocationGrid window(int rowStart, int rowWidth, int columnStart, int columnWidth)
rowStart - first row of windowrowWidth - number of rows in the windowcolumnStart - first column of windowcolumnWidth - public LocationGrid parent()
window(int, int, int, int). In this case, a
grid equivalent to this grid's greatest ancestor is returned.public Bounds bounds()
Locations in this grid. Method
delegates to Locations.bounds(Iterable).public static LocationGrid.Builder builder(int rows, int columns)
rows - expected number of rowscolumns - expected number of columnspublic static void main(String[] args)