Package com.google.common.collect
Class TreeRangeSet<C extends Comparable<?>>
java.lang.Object
com.google.common.collect.AbstractRangeSet<C>
com.google.common.collect.TreeRangeSet<C>
- All Implemented Interfaces:
RangeSet<C>
,Serializable
- Direct Known Subclasses:
TreeRangeSet.Complement
,TreeRangeSet.SubRangeSet
public class TreeRangeSet<C extends Comparable<?>>
extends AbstractRangeSet<C>
implements Serializable
- Since:
- 14.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) final class
private final class
private static final class
TreeRangeSet.ComplementRangesByLowerBound<C extends Comparable<?>>
(package private) static final class
TreeRangeSet.RangesByUpperBound<C extends Comparable<?>>
private final class
private static final class
TreeRangeSet.SubRangeSetRangesByLowerBound<C extends Comparable<?>>
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
TreeRangeSet
(NavigableMap<Cut<C>, Range<C>> rangesByLowerCut) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the specified range to thisRangeSet
(optional operation).Returns a descending view of the disconnected ranges that make up this range set.asRanges()
Returns a view of the disconnected ranges that make up this range set.Returns a view of the complement of thisRangeSet
.static <C extends Comparable<?>>
TreeRangeSet<C> create()
Creates an emptyTreeRangeSet
instance.static <C extends Comparable<?>>
TreeRangeSet<C> Returns aTreeRangeSet
initialized with the ranges in the specified range set.static <C extends Comparable<?>>
TreeRangeSet<C> Returns aTreeRangeSet
representing the union of the specified ranges.boolean
Returnstrue
if there exists a member range in this range set which encloses the specified range.boolean
intersects
(Range<C> range) Returnstrue
if there exists a non-empty range enclosed by both a member range in this range set and the specified range.rangeContaining
(C value) Returns the unique range from this range set that containsvalue
, ornull
if this range set does not containvalue
.rangeEnclosing
(Range<C> range) void
Removes the specified range from thisRangeSet
(optional operation).private void
replaceRangeWithSameLowerBound
(Range<C> range) span()
Returns the minimal range which encloses all ranges in this range set.subRangeSet
(Range<C> view) Returns a view of the intersection of thisRangeSet
with the specified range.Methods inherited from class com.google.common.collect.AbstractRangeSet
addAll, clear, contains, enclosesAll, equals, hashCode, isEmpty, removeAll, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.common.collect.RangeSet
addAll, enclosesAll, removeAll
-
Field Details
-
rangesByLowerBound
-
asRanges
-
asDescendingSetOfRanges
-
complement
-
-
Constructor Details
-
Method Details
-
create
Creates an emptyTreeRangeSet
instance. -
create
Returns aTreeRangeSet
initialized with the ranges in the specified range set. -
create
Returns aTreeRangeSet
representing the union of the specified ranges.This is the smallest
RangeSet
which encloses each of the specified ranges. An element will be contained in thisRangeSet
if and only if it is contained in at least oneRange
inranges
.- Since:
- 21.0
-
asRanges
Description copied from interface:RangeSet
Returns a view of the disconnected ranges that make up this range set. The returned set may be empty. The iterators returned by itsIterable.iterator()
method return the ranges in increasing order of lower bound (equivalently, of upper bound).- Specified by:
asRanges
in interfaceRangeSet<C extends Comparable<?>>
-
asDescendingSetOfRanges
Description copied from interface:RangeSet
Returns a descending view of the disconnected ranges that make up this range set. The returned set may be empty. The iterators returned by itsIterable.iterator()
method return the ranges in decreasing order of lower bound (equivalently, of upper bound).- Specified by:
asDescendingSetOfRanges
in interfaceRangeSet<C extends Comparable<?>>
-
rangeContaining
Description copied from interface:RangeSet
Returns the unique range from this range set that containsvalue
, ornull
if this range set does not containvalue
.- Specified by:
rangeContaining
in interfaceRangeSet<C extends Comparable<?>>
- Specified by:
rangeContaining
in classAbstractRangeSet<C extends Comparable<?>>
-
intersects
Description copied from interface:RangeSet
Returnstrue
if there exists a non-empty range enclosed by both a member range in this range set and the specified range. This is equivalent to callingsubRangeSet(otherRange)
and testing whether the resulting range set is non-empty.- Specified by:
intersects
in interfaceRangeSet<C extends Comparable<?>>
- Overrides:
intersects
in classAbstractRangeSet<C extends Comparable<?>>
-
encloses
Description copied from interface:RangeSet
Returnstrue
if there exists a member range in this range set which encloses the specified range.- Specified by:
encloses
in interfaceRangeSet<C extends Comparable<?>>
- Specified by:
encloses
in classAbstractRangeSet<C extends Comparable<?>>
-
rangeEnclosing
-
span
Description copied from interface:RangeSet
Returns the minimal range which encloses all ranges in this range set.- Specified by:
span
in interfaceRangeSet<C extends Comparable<?>>
-
add
Description copied from interface:RangeSet
Adds the specified range to thisRangeSet
(optional operation). That is, for equal range sets a and b, the result ofa.add(range)
is thata
will be the minimal range set for which botha.enclosesAll(b)
anda.encloses(range)
.Note that
range
will be coalesced with any ranges in the range set that are connected with it. Moreover, ifrange
is empty, this is a no-op.- Specified by:
add
in interfaceRangeSet<C extends Comparable<?>>
- Overrides:
add
in classAbstractRangeSet<C extends Comparable<?>>
-
remove
Description copied from interface:RangeSet
Removes the specified range from thisRangeSet
(optional operation). After this operation, ifrange.contains(c)
,this.contains(c)
will returnfalse
.If
range
is empty, this is a no-op.- Specified by:
remove
in interfaceRangeSet<C extends Comparable<?>>
- Overrides:
remove
in classAbstractRangeSet<C extends Comparable<?>>
-
replaceRangeWithSameLowerBound
-
complement
Description copied from interface:RangeSet
Returns a view of the complement of thisRangeSet
.The returned view supports the
RangeSet.add(com.google.common.collect.Range<C>)
operation if thisRangeSet
supportsRangeSet.remove(com.google.common.collect.Range<C>)
, and vice versa.- Specified by:
complement
in interfaceRangeSet<C extends Comparable<?>>
-
subRangeSet
Description copied from interface:RangeSet
Returns a view of the intersection of thisRangeSet
with the specified range.The returned view supports all optional operations supported by this
RangeSet
, with the caveat that anIllegalArgumentException
is thrown on an attempt to add any range not enclosed byview
.- Specified by:
subRangeSet
in interfaceRangeSet<C extends Comparable<?>>
-