Package com.gengoai.collection
Class HashBasedTable<R,C,V>
- java.lang.Object
-
- com.gengoai.collection.HashBasedTable<R,C,V>
-
- Type Parameters:
R
- the row type parameterC
- the column type parameterV
- the value type parameter
- All Implemented Interfaces:
Table<R,C,V>
,Serializable
public class HashBasedTable<R,C,V> extends Object implements Table<R,C,V>, Serializable
Table implementation using a map of maps.- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
HashBasedTable(List<TableEntry<R,C,V>> entryList)
-
Method Summary
All Methods Instance Methods Concrete 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 tableboolean
equals(Object o)
V
get(R row, C column)
Gets the value of the cell for the given row and column or null if not available.int
hashCode()
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 mappingsString
toString()
Collection<V>
values()
Collection of cell values in the table-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.gengoai.collection.Table
getOrDefault
-
-
-
-
Constructor Detail
-
HashBasedTable
protected HashBasedTable(List<TableEntry<R,C,V>> entryList)
-
-
Method Detail
-
clear
public void clear()
Description copied from interface:Table
Clears the table.
-
column
public Map<R,V> column(C column)
Description copied from interface:Table
Returns a map view for a column in the table
-
columnKeySet
public Set<C> columnKeySet()
Description copied from interface:Table
Returns a set of column keys that have one or more values associated- Specified by:
columnKeySet
in interfaceTable<R,C,V>
- Returns:
- the set of column keys that have one or more values associated
-
contains
public boolean contains(R row, C column)
Description copied from interface:Table
Checks if a value exists for a given row and column
-
containsColumn
public boolean containsColumn(C column)
Description copied from interface:Table
Checks if column key exists in the table- Specified by:
containsColumn
in interfaceTable<R,C,V>
- Parameters:
column
- the column- Returns:
- True if it exists, False otherwise
-
containsRow
public boolean containsRow(R row)
Description copied from interface:Table
Checks if row key exists in the table- Specified by:
containsRow
in interfaceTable<R,C,V>
- Parameters:
row
- the row- Returns:
- True if it exists, False otherwise
-
entrySet
public Set<TableEntry<R,C,V>> entrySet()
Description copied from interface:Table
Gets the set of entries in the table
-
get
public V get(R row, C column)
Description copied from interface:Table
Gets the value of the cell for the given row and column or null if not available.
-
put
public V put(R row, C column, V value)
Description copied from interface:Table
Sets the value of the cell at the given row and column
-
remove
public V remove(R row, C column)
Description copied from interface:Table
Removes the value at the given cell.
-
removeColumn
public Map<R,V> removeColumn(C column)
Description copied from interface:Table
Removes a column from the table- Specified by:
removeColumn
in interfaceTable<R,C,V>
- Parameters:
column
- the column- Returns:
- Map containing row, value pairs
-
removeRow
public Map<C,V> removeRow(R row)
Description copied from interface:Table
Removes a row from the table
-
row
public Map<C,V> row(R row)
Description copied from interface:Table
Returns a map view for a row in the table
-
rowKeySet
public Set<R> rowKeySet()
Description copied from interface:Table
Returns a set of row keys that have one or more values associated
-
size
public int size()
Description copied from interface:Table
The size in number of row and column mappings
-
-