Class TreeBasedTable<R,C,V>
java.lang.Object
cloud.opencode.base.collections.specialized.TreeBasedTable<R,C,V>
- Type Parameters:
R- row key type | 行键类型C- column key type | 列键类型V- value type | 值类型
- All Implemented Interfaces:
Table<R,C, V>, Serializable
TreeBasedTable - Tree-based Table Implementation
TreeBasedTable - 基于树的表实现
A table implementation using TreeMaps for sorted row and column keys.
使用 TreeMap 对行和列键进行排序的表实现。
Features | 主要功能:
- Sorted row and column keys - 排序的行和列键
- Natural or custom ordering - 自然或自定义排序
- Efficient range queries - 高效范围查询
Usage Examples | 使用示例:
TreeBasedTable<String, String, Integer> table = TreeBasedTable.create();
table.put("row1", "col1", 1);
table.put("row2", "col2", 2);
Integer value = table.get("row1", "col1"); // 1
// Rows and columns are sorted
for (String row : table.rowKeySet()) {
// Iterates in sorted order
}
Performance | 性能特性:
- get: O(log r + log c) where r=rows, c=columns - get: O(log r + log c)
- put: O(log r + log c) - put: O(log r + log c)
- containsRow/Column: O(log r/c) - containsRow/Column: O(log r/c)
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Null-safe: No (nulls not allowed) - 空值安全: 否(不允许空值)
- 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 TypeMethodDescriptionSet<Table.Cell<R, C, V>> cellSet()Return a view of all cells.voidclear()Clear all mappings.Return a map view for a specific column.Comparator<? super C> Return the column comparator.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 extends Comparable<? super R>, C extends Comparable<? super C>, V>
TreeBasedTable<R, C, V> create()Create an empty TreeBasedTable with natural ordering.static <R,C, V> TreeBasedTable <R, C, V> create(Comparator<? super R> rowComparator, Comparator<? super C> columnComparator) Create an empty TreeBasedTable with custom comparators.booleanGet 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.Comparator<? super R> Return the row comparator.Return a view of all row keys.rowMap()Return a map view of all rows.intsize()Return the number of row-column-value mappings.toString()values()Return a view of all values.
-
Method Details
-
create
public static <R extends Comparable<? super R>, C extends Comparable<? super C>, V> TreeBasedTable<R,C, create()V> Create an empty TreeBasedTable with natural ordering. 创建自然排序的空 TreeBasedTable。- Type Parameters:
R- row key type | 行键类型C- column key type | 列键类型V- value type | 值类型- Returns:
- new empty TreeBasedTable | 新空 TreeBasedTable
-
create
public static <R,C, TreeBasedTable<R,V> C, createV> (Comparator<? super R> rowComparator, Comparator<? super C> columnComparator) Create an empty TreeBasedTable with custom comparators. 创建自定义比较器的空 TreeBasedTable。- Type Parameters:
R- row key type | 行键类型C- column key type | 列键类型V- value type | 值类型- Parameters:
rowComparator- row comparator | 行比较器columnComparator- column comparator | 列比较器- Returns:
- new empty TreeBasedTable | 新空 TreeBasedTable
-
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
-
rowComparator
Return the row comparator. 返回行比较器。- Returns:
- the row comparator | 行比较器
-
columnComparator
Return the column comparator. 返回列比较器。- Returns:
- the column comparator | 列比较器
-
equals
-
hashCode
-
toString
-