|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.joda.collect.grid.ImmutableGrid<V>
V - the type of the valuepublic abstract class ImmutableGrid<V>
Immutable implementation of the Grid data structure.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.joda.collect.grid.Grid |
|---|
Grid.Cell<V> |
| Method Summary | ||
|---|---|---|
Grid.Cell<V> |
cell(int row,
int column)
Gets the cell at the specified row-column. |
|
void |
clear()
Deprecated. Grid is read-only |
|
List<V> |
column(int column)
Gets the rows of a single column. |
|
List<List<V>> |
columns()
Gets the entire grid of values, by column then row. |
|
boolean |
contains(int row,
int column)
Checks if a value is present at the specified row-column. |
|
boolean |
containsValue(Object valueToFind)
Checks if the specified value is contained in the grid. |
|
static
|
copyOf(Grid<R> grid)
Obtains an immutable grid by copying another grid. |
|
static
|
copyOf(int rowCount,
int columnCount,
Grid.Cell<R> cell)
Obtains an immutable grid with one cell. |
|
static
|
copyOf(int rowCount,
int columnCount,
Iterable<? extends Grid.Cell<R>> cells)
Obtains an immutable grid by copying a set of cells. |
|
static
|
copyOfDeriveCounts(Iterable<? extends Grid.Cell<R>> cells)
Obtains an immutable grid by copying a set of cells, deriving the row and column count. |
|
boolean |
equals(Object obj)
Checks if this grid equals another grid. |
|
boolean |
exists(int row,
int column)
Checks if the specified row-column exists. |
|
V |
get(int row,
int column)
Gets the value at the specified row-column. |
|
int |
hashCode()
Gets a suitable hash code. |
|
boolean |
isEmpty()
Checks if the grid is empty. |
|
boolean |
isFull()
Checks if the grid is full. |
|
static
|
of()
Obtains an empty immutable grid with zero row-column count. |
|
static
|
of(int rowCount,
int columnCount)
Obtains an empty immutable grid of the specified row-column count. |
|
static
|
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
|
of(R value)
Obtains an immutable grid with row-column count 1x1 and a single cell. |
|
void |
put(int row,
int column,
V value)
Deprecated. Grid is read-only |
|
void |
putAll(Grid<? extends V> grid)
Deprecated. Grid is read-only |
|
boolean |
remove(int row,
int column)
Deprecated. Grid is read-only |
|
List<V> |
row(int row)
Gets the columns of a single row. |
|
List<List<V>> |
rows()
Gets the entire grid of values, by row then column. |
|
int |
size()
Gets the number of cells that are present. |
|
String |
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, wait |
| Methods inherited from interface org.joda.collect.grid.Grid |
|---|
cells, columnCount, rowCount |
| Method Detail |
|---|
public static <R> ImmutableGrid<R> of()
R - the type of the value
public static <R> ImmutableGrid<R> of(int rowCount,
int columnCount)
R - the type of the valuerowCount - the number of rows, zero or greatercolumnCount - the number of columns, zero or greater
public static <R> ImmutableGrid<R> of(R value)
The single cell is at row zero column zero.
R - the type of the valuevalue - the value of the single cell, not null
public static <R> ImmutableGrid<R> of(int rowCount,
int columnCount,
int row,
int column,
R value)
R - the type of the valuerowCount - 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
public static <R> ImmutableGrid<R> copyOf(int rowCount,
int columnCount,
Grid.Cell<R> cell)
R - the type of the valuerowCount - the number of rows, zero or greatercolumnCount - the number of columns, zero or greatercell - the cell that the grid should contain, not null
IndexOutOfBoundsException - if either index is less than zero
public static <R> ImmutableGrid<R> copyOf(int rowCount,
int columnCount,
Iterable<? extends Grid.Cell<R>> cells)
R - the type of the valuerowCount - the number of rows, zero or greatercolumnCount - the number of columns, zero or greatercells - the cells to copy, not null
IndexOutOfBoundsException - if either index is less than zeropublic static <R> ImmutableGrid<R> copyOfDeriveCounts(Iterable<? extends Grid.Cell<R>> cells)
The row and column counts are calculated as the maximum row and column specified.
R - the type of the valuecells - the cells to copy, not null
IndexOutOfBoundsException - if either index is less than zeropublic static <R> ImmutableGrid<R> copyOf(Grid<R> grid)
If you need to change the row-column count, use copyOf(int, int, Iterable)
passing in the set of cells from the grid.
R - the type of the valuegrid - the grid to copy, not null
IndexOutOfBoundsException - if either index is less than zero@Deprecated public void clear()
The grid will be empty after calling this method.
@Deprecated
public void put(int row,
int column,
V value)
The value at the specified row-column is set. Any previous value at the row-column is replaced.
If either index does not exist, IndexOutOfBoundsException is thrown.
row - the row, zero or greatercolumn - the column, zero or greatervalue - the value to put into the grid, not null@Deprecated public void putAll(Grid<? extends V> grid)
The value at the specified row-column is set. Any previous value at the row-column is replaced.
grid - the grid to put into this grid, not null
@Deprecated
public boolean remove(int row,
int column)
If either index does not exist, no action occurs and false is returned.
row - the rowcolumn - the column
public boolean exists(int row,
int column)
GridThis simply checks that the row and column indices are between zero and the row and column counts.
exists in interface Grid<V>row - the rowcolumn - the column
public boolean isFull()
GridA full grid has a cell at every combination of row and column.
isFull in interface Grid<V>public boolean isEmpty()
Grid
isEmpty in interface Grid<V>public int size()
Grid
size in interface Grid<V>
public boolean contains(int row,
int column)
GridIf either index does not exist, false is returned.
contains in interface Grid<V>row - the rowcolumn - the column
public boolean containsValue(Object valueToFind)
Grid
containsValue in interface Grid<V>valueToFind - the value to find, null returns false
public V get(int row,
int column)
GridIf either index does not exist, null is returned.
get in interface Grid<V>row - the rowcolumn - the column
public Grid.Cell<V> cell(int row,
int column)
GridIf either index does not exist, null is returned.
cell in interface Grid<V>row - the rowcolumn - the column
public com.google.common.collect.ImmutableCollection<V> values()
GridThe returned data structure is an ordered collection. The values are returned in order, looping around rows, then columns.
values in interface Grid<V>public List<V> row(int row)
Grid
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.
row in interface Grid<V>row - the row, zero or greater
public List<List<V>> rows()
Grid
The outer list contains all rows from zero to rowCount.
Each inner list contains all columns from zero to columnCount.
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.
rows in interface Grid<V>public List<V> column(int column)
Grid
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.
column in interface Grid<V>column - the column, zero or greater
public List<List<V>> columns()
Grid
The outer list contains all columns from zero to columnCount.
Each inner list contains all rows from zero to rowCount.
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.
columns in interface Grid<V>public boolean equals(Object obj)
GridTwo grids are equal if they are the same size and contain the same set of cells.
equals in interface Grid<V>equals in class Objectobj - the object to compare to, null returns false
public int hashCode()
Grid
The hash code is rowCount ^ Integer.rotateLeft(columnCount, 16) ^ cells.hashCode().
hashCode in interface Grid<V>hashCode in class Objectpublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||