Class ArrayTable<R,C,V>
java.lang.Object
cloud.opencode.base.collections.specialized.ArrayTable<R,C,V>
- Type Parameters:
R- row key type | 行键类型C- column key type | 列键类型V- value type | 值类型
- All Implemented Interfaces:
Table<R,C, V>, Serializable
ArrayTable - Fixed-size Array-based Table Implementation
ArrayTable - 固定大小基于数组的表实现
A table implementation using a 2D array with fixed row and column keys.
使用具有固定行和列键的二维数组的表实现。
Features | 主要功能:
- Fixed dimensions - 固定维度
- O(1) access - O(1) 访问
- Dense storage - 密集存储
- Allows null values - 允许空值
Usage Examples | 使用示例:
ArrayTable<String, String, Integer> table = ArrayTable.create(
Arrays.asList("row1", "row2"),
Arrays.asList("col1", "col2"));
table.put("row1", "col1", 1);
table.put("row1", "col2", 2);
Integer value = table.get("row1", "col1"); // 1
// Direct array access
Integer[][] array = table.toArray();
Performance | 性能特性:
- get: O(1) - get: O(1)
- put: O(1) - put: O(1)
- containsRow/Column: O(1) - containsRow/Column: O(1)
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Null-safe: Values can be null - 空值安全: 值可以为 null
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Table
Table.Cell<R,C, V> -
Method Summary
Modifier and TypeMethodDescriptionat(int rowIndex, int columnIndex) Return the value at the given indices.Set<Table.Cell<R, C, V>> cellSet()Return a view of all cells.voidclear()Clear all mappings.Return a map view for a specific column.Return all column keys in order.Return a view of all column keys.Return a map view of all columns.booleanCheck if the table contains a mapping with the row and column keys.booleancontainsColumn(Object columnKey) Check if the table contains a mapping with the column key.booleancontainsRow(Object rowKey) Check if the table contains a mapping with the row key.booleancontainsValue(Object value) Check if the table contains a mapping with the value.static <R,C, V> ArrayTable <R, C, V> Create an ArrayTable copying from another table.static <R,C, V> ArrayTable <R, C, V> Create an ArrayTable with the specified row and column keys.booleanerase(int rowIndex, int columnIndex) Erase the value at the given indices.Get the value at the specified row and column.inthashCode()booleanisEmpty()Check if the table contains any mappings.Put a value at the specified row and column.voidPut all values from another table.Remove the value at the specified row and column.Return a map view for a specific row.Return all row keys in order.Return a view of all row keys.rowMap()Return a map view of all rows.Set the value at the given indices.intsize()Return the number of row-column-value mappings.V[][]Return the values as a 2D array.toString()values()Return a view of all values.
-
Method Details
-
create
public static <R,C, ArrayTable<R,V> C, createV> (Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) Create an ArrayTable with the specified row and column keys. 使用指定的行和列键创建 ArrayTable。- Type Parameters:
R- row key type | 行键类型C- column key type | 列键类型V- value type | 值类型- Parameters:
rowKeys- the row keys | 行键columnKeys- the column keys | 列键- Returns:
- new ArrayTable | 新 ArrayTable
-
create
Create an ArrayTable copying from another table. 从另一个表复制创建 ArrayTable。- Type Parameters:
R- row key type | 行键类型C- column key type | 列键类型V- value type | 值类型- Parameters:
table- the table to copy | 要复制的表- Returns:
- new ArrayTable | 新 ArrayTable
-
get
-
contains
Description copied from interface:TableCheck if the table contains a mapping with the row and column keys. 检查表是否包含指定行列键的映射。 -
containsRow
-
containsColumn
-
containsValue
-
put
Description copied from interface:TablePut a value at the specified row and column. 在指定行列放入值。 -
putAll
-
remove
Description copied from interface:TableRemove the value at the specified row and column. 移除指定行列的值。 -
row
-
column
-
cellSet
-
rowKeySet
-
columnKeySet
-
values
-
rowMap
-
columnMap
-
size
-
isEmpty
-
clear
-
rowKeyList
-
columnKeyList
-
at
Return the value at the given indices. 返回给定索引处的值。- Parameters:
rowIndex- the row index | 行索引columnIndex- the column index | 列索引- Returns:
- the value | 值
-
set
-
erase
Erase the value at the given indices. 擦除给定索引处的值。- Parameters:
rowIndex- the row index | 行索引columnIndex- the column index | 列索引- Returns:
- the old value | 旧值
-
toArray
-
equals
-
hashCode
-
toString
-