Interface RangeSet<C extends Comparable<? super C>>
- Type Parameters:
C- the type of range endpoints | 范围端点类型
- All Known Implementing Classes:
ImmutableRangeSet, TreeRangeSet
public interface RangeSet<C extends Comparable<? super C>>
RangeSet - Range Set Interface
RangeSet - 范围集合接口
A set of ranges that automatically coalesces overlapping and adjacent ranges.
自动合并重叠和相邻范围的范围集合。
Features | 主要功能:
- Automatic range coalescing - 自动范围合并
- Efficient range queries - 高效范围查询
- Complement and intersection operations - 补集和交集操作
Usage Examples | 使用示例:
RangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 10)); // {[1, 10]}
rangeSet.add(Range.closed(5, 15)); // {[1, 15]} (coalesced)
rangeSet.add(Range.closed(20, 30)); // {[1, 15], [20, 30]}
boolean contains = rangeSet.contains(5); // true
Range<Integer> enclosing = rangeSet.rangeContaining(5); // [1, 15]
Security | 安全性:
- Thread-safe: No (interface, implementation-dependent) - 否(接口,取决于实现)
- Null-safe: No (range 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 TypeMethodDescriptionvoidAdd a range to this set.voidAdd all ranges from another range set.Return all ranges as a descending set.asRanges()Return all ranges as a set.voidclear()Clear all ranges.Return the complement of this range set.booleanCheck if the value is contained in any range.booleanCheck if this range set encloses the given range.booleanenclosesAll(RangeSet<C> other) Check if this range set encloses all ranges in the other set.booleanintersects(Range<C> otherRange) Check if this range set intersects the given range.booleanisEmpty()Check if this range set is empty.rangeContaining(C value) Return the range containing the value, or null.voidRemove a range from this set.voidRemove all ranges in another range set.span()Return the minimal range that encloses all ranges.subRangeSet(Range<C> view) Return a sub range set within the given range.
-
Method Details
-
contains
Check if the value is contained in any range. 检查值是否包含在任何范围中。- Parameters:
value- the value | 值- Returns:
- true if contained | 如果包含则返回 true
-
rangeContaining
-
encloses
-
enclosesAll
-
intersects
-
isEmpty
boolean isEmpty()Check if this range set is empty. 检查此范围集合是否为空。- Returns:
- true if empty | 如果为空则返回 true
-
asRanges
-
asDescendingSetOfRanges
-
complement
-
subRangeSet
-
span
-
add
-
remove
-
addAll
-
removeAll
-
clear
void clear()Clear all ranges. 清除所有范围。
-