Class HashBasedTable<R,C,V>
- All Implemented Interfaces:
Table<R,
,C, V> Serializable
Table
using linked hash tables. This guarantees predictable iteration
order of the various views.
The views returned by StandardTable.column(C)
, StandardTable.columnKeySet()
, and StandardTable.columnMap()
have
iterators that don't support remove()
. Otherwise, all optional operations are supported.
Null row keys, columns keys, and values are not supported.
Lookups by row key are often faster than lookups by column key, because the data is stored in
a Map<R, Map<C, V>>
. A method call like column(columnKey).get(rowKey)
still runs
quickly, since the row key is provided. However, column(columnKey).size()
takes longer,
since an iteration across all row keys occurs.
Note that this implementation is not synchronized. If multiple threads access this table concurrently and one of the threads modifies the table, it must be synchronized externally.
See the Guava User Guide article on Table
.
- Since:
- 7.0
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.google.common.collect.StandardTable
StandardTable.Row, StandardTable.RowMap
Nested classes/interfaces inherited from class com.google.common.collect.AbstractTable
AbstractTable.CellSet, AbstractTable.Values
Nested classes/interfaces inherited from interface com.google.common.collect.Table
Table.Cell<R,
C, V> -
Field Summary
FieldsFields inherited from class com.google.common.collect.StandardTable
backingMap, factory
-
Constructor Summary
ConstructorsConstructorDescriptionHashBasedTable
(Map<R, Map<C, V>> backingMap, HashBasedTable.Factory<C, V> factory) -
Method Summary
Modifier and TypeMethodDescriptionstatic <R,
C, V> HashBasedTable <R, C, V> create()
Creates an emptyHashBasedTable
.static <R,
C, V> HashBasedTable <R, C, V> create
(int expectedRows, int expectedCellsPerRow) Creates an emptyHashBasedTable
with the specified map sizes.static <R,
C, V> HashBasedTable <R, C, V> Creates aHashBasedTable
with the same mappings as the specified table.Methods inherited from class com.google.common.collect.StandardTable
cellIterator, cellSet, cellSpliterator, clear, column, columnKeySet, columnMap, contains, containsColumn, containsRow, containsValue, createColumnKeyIterator, createRowMap, get, isEmpty, put, remove, row, rowKeySet, rowMap, size, values
Methods inherited from class com.google.common.collect.AbstractTable
createCellSet, createValues, equals, hashCode, putAll, toString, valuesIterator, valuesSpliterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
HashBasedTable
-
-
Method Details
-
create
Creates an emptyHashBasedTable
. -
create
Creates an emptyHashBasedTable
with the specified map sizes.- Parameters:
expectedRows
- the expected number of distinct row keysexpectedCellsPerRow
- the expected number of column key / value mappings in each row- Throws:
IllegalArgumentException
- ifexpectedRows
orexpectedCellsPerRow
is negative
-
create
public static <R,C, HashBasedTable<R,V> C, createV> (Table<? extends R, ? extends C, ? extends V> table) Creates aHashBasedTable
with the same mappings as the specified table.- Parameters:
table
- the table to copy- Throws:
NullPointerException
- if any of the row keys, column keys, or values intable
is null
-