Class TreeRangeMap<K extends Comparable<? super K>, V>
java.lang.Object
cloud.opencode.base.collections.specialized.TreeRangeMap<K,V>
- Type Parameters:
K- the type of range endpoints | 范围端点类型V- the type of values | 值类型
- All Implemented Interfaces:
RangeMap<K,V>, Serializable
public final class TreeRangeMap<K extends Comparable<? super K>, V>
extends Object
implements RangeMap<K,V>, Serializable
TreeRangeMap - Tree-based Range Map Implementation
TreeRangeMap - 基于树的范围映射实现
A range map implementation using a tree structure for efficient range operations.
使用树结构进行高效范围操作的范围映射实现。
Features | 主要功能:
- Automatic range coalescing - 自动范围合并
- O(log n) operations - O(log n) 操作
- Efficient range queries - 高效范围查询
Usage Examples | 使用示例:
TreeRangeMap<Integer, String> rangeMap = TreeRangeMap.create();
rangeMap.put(Range.closed(1, 10), "small");
rangeMap.put(Range.closed(11, 100), "medium");
String value = rangeMap.get(5); // "small"
Performance | 性能特性:
- get: O(log n) - get: O(log n)
- put: O(log n + k) where k is removed ranges - put: O(log n + k) 其中 k 是移除的范围数
- remove: O(log n + k) - remove: O(log n + k)
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Null-safe: Values cannot be null - 空值安全: 值不能为 null
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturn all range-value mappings in descending order.Return all range-value mappings as a map.voidclear()Clear all mappings.static <K extends Comparable<? super K>, V>
TreeRangeMap<K, V> create()Create an empty TreeRangeMap.booleanGet the value associated with the key.Get the entry (range and value) containing the key.inthashCode()booleanisEmpty()Check if this range map is empty.voidAssociate a range with a value.voidPut all mappings from another range map.voidputCoalescing(Range<K> range, V value) Associate a range with a value, coalescing with adjacent ranges with the same value.voidRemove a range from this map.span()Return the minimal range that encloses all ranges in this map.subRangeMap(Range<K> range) Return a view of the portion of this map within the given range.toString()
-
Method Details
-
create
Create an empty TreeRangeMap. 创建空 TreeRangeMap。- Type Parameters:
K- endpoint type | 端点类型V- value type | 值类型- Returns:
- new empty TreeRangeMap | 新空 TreeRangeMap
-
get
-
getEntry
Description copied from interface:RangeMapGet the entry (range and value) containing the key. 获取包含键的条目(范围和值)。 -
span
-
isEmpty
-
asMapOfRanges
-
asDescendingMapOfRanges
-
subRangeMap
Description copied from interface:RangeMapReturn a view of the portion of this map within the given range. 返回此映射在给定范围内的部分的视图。- Specified by:
subRangeMapin interfaceRangeMap<K extends Comparable<? super K>, V>- Parameters:
range- the range | 范围- Returns:
- the sub range map | 子范围映射
-
put
-
putCoalescing
Description copied from interface:RangeMapAssociate a range with a value, coalescing with adjacent ranges with the same value. 将范围与值关联,与具有相同值的相邻范围合并。- Specified by:
putCoalescingin interfaceRangeMap<K extends Comparable<? super K>, V>- Parameters:
range- the range | 范围value- the value | 值
-
putAll
-
remove
-
clear
-
equals
-
hashCode
-
toString
-