- Type Parameters:
V- the type of the value
- All Implemented Interfaces:
Grid<V>
Grid data structure.-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptioncell(int row, int column) Gets the cell at the specified row-column.voidclear()Deprecated.Grid is read-onlycolumn(int column) Gets the rows of a single column.columns()Gets the entire grid of values, by column then row.booleancontains(int row, int column) Checks if a value is present at the specified row-column.booleancontainsValue(Object valueToFind) Checks if the specified value is contained in the grid.static <R> ImmutableGrid<R> Obtains an immutable grid by copying a set of cells.static <R> ImmutableGrid<R> Obtains an immutable grid with one cell.static <R> ImmutableGrid<R> Obtains an immutable grid by copying another grid.static <R> ImmutableGrid<R> copyOfDeriveCounts(Iterable<? extends Grid.Cell<R>> cells) Obtains an immutable grid by copying a set of cells, deriving the row and column count.booleanChecks if this grid equals another grid.booleanexists(int row, int column) Checks if the specified row-column exists.get(int row, int column) Gets the value at the specified row-column.inthashCode()Gets a suitable hash code.booleanisEmpty()Checks if the grid is empty.booleanisFull()Checks if the grid is full.static <R> ImmutableGrid<R> of()Obtains an empty immutable grid with zero row-column count.static <R> ImmutableGrid<R> of(int rowCount, int columnCount) Obtains an empty immutable grid of the specified row-column count.static <R> ImmutableGrid<R> of(int rowCount, int columnCount, int row, int column, R value) Obtains an immutable grid of the specified row-column count with a single cell.static <R> ImmutableGrid<R> of(R value) Obtains an immutable grid with row-column count 1x1 and a single cell.voidDeprecated.Grid is read-onlyvoidDeprecated.Grid is read-onlybooleanremove(int row, int column) Deprecated.Grid is read-onlyrow(int row) Gets the columns of a single row.rows()Gets the entire grid of values, by row then column.intsize()Gets the number of cells that are present.toString()com.google.common.collect.ImmutableCollection<V> values()Gets the values in order through rows, then columns.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.joda.collect.grid.Grid
cells, columnCount, rowCount
-
Method Details
-
of
Obtains an empty immutable grid with zero row-column count.- Type Parameters:
R- the type of the value- Returns:
- the empty immutable grid, not null
-
of
Obtains an empty immutable grid of the specified row-column count.- Type Parameters:
R- the type of the value- Parameters:
rowCount- the number of rows, zero or greatercolumnCount- the number of columns, zero or greater- Returns:
- the empty immutable grid, not null
-
of
Obtains an immutable grid with row-column count 1x1 and a single cell.The single cell is at row zero column zero.
- Type Parameters:
R- the type of the value- Parameters:
value- the value of the single cell, not null- Returns:
- the empty immutable grid, not null
-
of
Obtains an immutable grid of the specified row-column count with a single cell.- Type Parameters:
R- the type of the value- Parameters:
rowCount- the number of rows, zero or greatercolumnCount- the number of columns, zero or greaterrow- the row of the single cell, zero or greatercolumn- the column of the single cell, zero or greatervalue- the value of the single cell, not null- Returns:
- the empty immutable grid, not null
-
copyOf
Obtains an immutable grid with one cell.- Type Parameters:
R- the type of the value- Parameters:
rowCount- the number of rows, zero or greatercolumnCount- the number of columns, zero or greatercell- the cell that the grid should contain, not null- Returns:
- the immutable grid, not null
- Throws:
IndexOutOfBoundsException- if either index is less than zero
-
copyOf
public static <R> ImmutableGrid<R> copyOf(int rowCount, int columnCount, Iterable<? extends Grid.Cell<R>> cells) Obtains an immutable grid by copying a set of cells.- Type Parameters:
R- the type of the value- Parameters:
rowCount- the number of rows, zero or greatercolumnCount- the number of columns, zero or greatercells- the cells to copy, not null- Returns:
- the immutable grid, not null
- Throws:
IndexOutOfBoundsException- if either index is less than zero
-
copyOfDeriveCounts
Obtains an immutable grid by copying a set of cells, deriving the row and column count.The row and column counts are calculated as the maximum row and column specified.
- Type Parameters:
R- the type of the value- Parameters:
cells- the cells to copy, not null- Returns:
- the immutable grid, not null
- Throws:
IndexOutOfBoundsException- if either index is less than zero
-
copyOf
Obtains an immutable grid by copying another grid.If you need to change the row-column count, use
copyOf(int, int, Iterable)passing in the set of cells from the grid.- Type Parameters:
R- the type of the value- Parameters:
grid- the grid to copy, not null- Returns:
- the immutable grid, not null
- Throws:
IndexOutOfBoundsException- if either index is less than zero
-
clear
Deprecated.Grid is read-onlyClears the grid.The grid will be empty after calling this method.
-
put
Deprecated.Grid is read-onlyPuts a value into this grid.The value at the specified row-column is set. Any previous value at the row-column is replaced.
If either index does not exist,
IndexOutOfBoundsExceptionis thrown.- Parameters:
row- the row, zero or greatercolumn- the column, zero or greatervalue- the value to put into the grid, not null
-
putAll
Deprecated.Grid is read-onlyPuts all cells from a grid into this grid.The value at the specified row-column is set. Any previous value at the row-column is replaced.
- Parameters:
grid- the grid to put into this grid, not null
-
remove
Deprecated.Grid is read-onlyRemoves the value at the specified row-column.If either index does not exist, no action occurs and false is returned.
- Parameters:
row- the rowcolumn- the column- Returns:
- true if the grid is altered
-
exists
public boolean exists(int row, int column) Description copied from interface:GridChecks if the specified row-column exists.This simply checks that the row and column indices are between zero and the row and column counts.
-
isFull
public boolean isFull()Description copied from interface:GridChecks if the grid is full.A full grid has a cell at every combination of row and column.
-
isEmpty
public boolean isEmpty()Description copied from interface:GridChecks if the grid is empty. -
size
public int size()Description copied from interface:GridGets the number of cells that are present. -
contains
public boolean contains(int row, int column) Description copied from interface:GridChecks if a value is present at the specified row-column.If either index does not exist, false is returned.
-
containsValue
Description copied from interface:GridChecks if the specified value is contained in the grid.- Specified by:
containsValuein interfaceGrid<V>- Parameters:
valueToFind- the value to find, null returns false- Returns:
- true if the grid contains the value
-
get
Description copied from interface:GridGets the value at the specified row-column.If either index does not exist, null is returned.
-
cell
Description copied from interface:GridGets the cell at the specified row-column.If either index does not exist, null is returned.
-
values
Description copied from interface:GridGets the values in order through rows, then columns.The returned data structure is an ordered collection. The values are returned in order, looping around rows, then columns.
-
row
Description copied from interface:GridGets the columns of a single row.The list will contain all columns from zero to
columnCount. Where there is no value for a cell, the list will contain null.The returned list is immutable, except for
List.set(int, Object), which adds, updates or deletes from the underlying grid. -
rows
Description copied from interface:GridGets the entire grid of values, by row then column.The outer list contains all rows from zero to
rowCount. Each inner list contains all columns from zero tocolumnCount. Where there is no value for a cell, the value is null.The returned list is immutable, except for the
List.set(int, Object)method on the inner list, which adds, updates or deletes from the underlying grid. -
column
Description copied from interface:GridGets the rows of a single column.The list will contain all rows from zero to
rowCount. Where data is not present, the list will contain null.The returned list is immutable, except for
List.set(int, Object), which adds, updates or deletes from the underlying grid. -
columns
Description copied from interface:GridGets the entire grid of values, by column then row.The outer list contains all columns from zero to
columnCount. Each inner list contains all rows from zero torowCount. Where there is no value for a cell, the value is null.The returned list is immutable, except for the
List.set(int, Object)method on the inner list, which adds, updates or deletes from the underlying grid. -
equals
Description copied from interface:GridChecks if this grid equals another grid.Two grids are equal if they are the same size and contain the same set of cells.
-
hashCode
public int hashCode()Description copied from interface:GridGets a suitable hash code.The hash code is
rowCount ^ Integer.rotateLeft(columnCount, 16) ^ cells.hashCode(). -
toString
-