Package com.gengoai.collection
Interface Table<R,C,V>
-
- Type Parameters:
R
- the row type parameterC
- the column type parameterV
- the value type parameter
- All Known Implementing Classes:
HashBasedTable
public interface Table<R,C,V>
A table is a two dimensional structure that associates a value with two keys (i.e. a row and column key). A table maybe sparse, meaning not all cells contain values. Methods on a table that work with rows and columns return Map views that when updated will be reflected in table.- Author:
- David B. Bracewell
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
clear()
Clears the table.Map<R,V>
column(C column)
Returns a map view for a column in the tableSet<C>
columnKeySet()
Returns a set of column keys that have one or more values associatedboolean
contains(R row, C column)
Checks if a value exists for a given row and columnboolean
containsColumn(C column)
Checks if column key exists in the tableboolean
containsRow(R row)
Checks if row key exists in the tableSet<TableEntry<R,C,V>>
entrySet()
Gets the set of entries in the tableV
get(R row, C column)
Gets the value of the cell for the given row and column or null if not available.default V
getOrDefault(R row, C column, V defaultValue)
V
put(R row, C column, V value)
Sets the value of the cell at the given row and columnV
remove(R row, C column)
Removes the value at the given cell.Map<R,V>
removeColumn(C column)
Removes a column from the tableMap<C,V>
removeRow(R row)
Removes a row from the tableMap<C,V>
row(R row)
Returns a map view for a row in the tableSet<R>
rowKeySet()
Returns a set of row keys that have one or more values associatedint
size()
The size in number of row and column mappingsCollection<V>
values()
Collection of cell values in the table
-
-
-
Method Detail
-
clear
void clear()
Clears the table.
-
column
Map<R,V> column(C column)
Returns a map view for a column in the table- Parameters:
column
- the column- Returns:
- Map of row,value pairs
-
columnKeySet
Set<C> columnKeySet()
Returns a set of column keys that have one or more values associated- Returns:
- the set of column keys that have one or more values associated
-
contains
boolean contains(R row, C column)
Checks if a value exists for a given row and column- Parameters:
row
- the rowcolumn
- the column- Returns:
- True if it exists, False otherwise
-
containsColumn
boolean containsColumn(C column)
Checks if column key exists in the table- Parameters:
column
- the column- Returns:
- True if it exists, False otherwise
-
containsRow
boolean containsRow(R row)
Checks if row key exists in the table- Parameters:
row
- the row- Returns:
- True if it exists, False otherwise
-
entrySet
Set<TableEntry<R,C,V>> entrySet()
Gets the set of entries in the table- Returns:
- the set of entries
-
get
V get(R row, C column)
Gets the value of the cell for the given row and column or null if not available.- Parameters:
row
- the rowcolumn
- the column- Returns:
- the value of the cell at the given row and column or null
-
put
V put(R row, C column, V value)
Sets the value of the cell at the given row and column- Parameters:
row
- the rowcolumn
- the columnvalue
- the value- Returns:
- the previous value
-
remove
V remove(R row, C column)
Removes the value at the given cell.- Parameters:
row
- the rowcolumn
- the column- Returns:
- the value of the cell
-
removeColumn
Map<R,V> removeColumn(C column)
Removes a column from the table- Parameters:
column
- the column- Returns:
- Map containing row, value pairs
-
removeRow
Map<C,V> removeRow(R row)
Removes a row from the table- Parameters:
row
- the row- Returns:
- Map containing column, value pairs
-
row
Map<C,V> row(R row)
Returns a map view for a row in the table- Parameters:
row
- the row- Returns:
- Map of column,value pairs
-
rowKeySet
Set<R> rowKeySet()
Returns a set of row keys that have one or more values associated- Returns:
- the set of row keys that have one or more values associated
-
size
int size()
The size in number of row and column mappings- Returns:
- number of row and column mappings
-
values
Collection<V> values()
Collection of cell values in the table- Returns:
- the collection of cell values in the table
-
-