Interface RangeMap<K extends Comparable<? super K>, V>
- Type Parameters:
K- the type of range endpoints | 范围端点类型V- the type of values | 值类型
- All Known Implementing Classes:
ImmutableRangeMap, TreeRangeMap
public interface RangeMap<K extends Comparable<? super K>, V>
RangeMap - Range Map Interface
RangeMap - 范围映射接口
A mapping from disjoint non-empty ranges to values.
从不相交的非空范围到值的映射。
Features | 主要功能:
- Automatic range coalescing - 自动范围合并
- Efficient range-based lookup - 高效的基于范围的查找
- Range-value association - 范围-值关联
Usage Examples | 使用示例:
RangeMap<Integer, String> rangeMap = TreeRangeMap.create();
rangeMap.put(Range.closed(1, 10), "small");
rangeMap.put(Range.closed(11, 100), "medium");
rangeMap.put(Range.closed(101, 1000), "large");
String value = rangeMap.get(5); // "small"
String value2 = rangeMap.get(50); // "medium"
Security | 安全性:
- Thread-safe: No (interface, implementation-dependent) - 否(接口,取决于实现)
- Null-safe: No (key must not 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.Get the value associated with the key.Get the entry (range and value) containing the key.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.
-
Method Details
-
get
-
getEntry
-
span
-
isEmpty
boolean isEmpty()Check if this range map is empty. 检查此范围映射是否为空。- Returns:
- true if empty | 如果为空则返回 true
-
asMapOfRanges
-
asDescendingMapOfRanges
-
subRangeMap
-
put
-
putCoalescing
-
putAll
-
remove
-
clear
void clear()Clear all mappings. 清除所有映射。
-