C.
Implementations that choose to support the add(Range) operation are required to
ignore empty ranges and coalesce connected ranges. For example:
RangeSet<Integer> rangeSet = TreeRangeSet.create();
rangeSet.add(Range.closed(1, 10)); // {[1, 10]}
rangeSet.add(Range.closedOpen(11, 15)); // disconnected range; {[1, 10], [11, 15)}
rangeSet.add(Range.closedOpen(15, 20)); // connected range; {[1, 10], [11, 20)}
rangeSet.add(Range.openClosed(0, 0)); // empty range; {[1, 10], [11, 20)}
rangeSet.remove(Range.open(5, 10)); // splits [1, 10]; {[1, 5], [10, 10], [11, 20)}
Note that the behavior of Range#isEmpty() and Range#isConnected(Range) may not
be as expected on discrete ranges. See the Javadoc of those methods for details.
For a Set whose contents are specified by a Range, see ContiguousSet.
See the Guava User Guide article on RangeSets.
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public default void | |
| public Set | asDescendingSetOfRanges()
Returns a descending view of the disconnected ranges that make up this range set. |
| public Set | |
| public void | |
| public RangeSet | |
| public boolean | |
| public boolean | |
| public boolean | enclosesAll(RangeSet<C> other)
Returns |
| public default boolean | enclosesAll(Iterable<Range<C>> other)
Returns |
| public boolean | equals(Object obj)
Returns |
| public int | |
| public boolean | intersects(Range<C> otherRange)
Returns |
| public boolean | |
| public Range | rangeContaining(C value)
Returns the unique range from this range set that contains |
| public void | |
| public void | |
| public default void | |
| public Range | |
| public RangeSet | subRangeSet(Range<C> view)
Returns a view of the intersection of this |
| public String |
| add | back to summary |
|---|---|
| public void add(Range<C> range) Adds the specified range to this Note that
| |
| addAll | back to summary |
|---|---|
| public void addAll(RangeSet<C> other) Adds all of the ranges from the specified range set to this range set (optional operation).
After this operation, this range set is the minimal range set that encloses both the original range set and This is equivalent to calling
| |
| addAll | back to summary |
|---|---|
| public default void addAll(Iterable<Range<C>> ranges) Adds all of the specified ranges to this range set (optional operation). After this operation,
this range set is the minimal range set that encloses both
the original range set and each range in This is equivalent to calling
| |
| asDescendingSetOfRanges | back to summary |
|---|---|
| public Set Returns a descending view of the disconnected ranges that make
up this range set. The returned set may be empty. The iterators returned by its
| |
| asRanges | back to summary |
|---|---|
| public Set Returns a view of the disconnected ranges that make up this
range set. The returned set may be empty. The iterators returned by its | |
| clear | back to summary |
|---|---|
| public void clear() Removes all ranges from this This is equivalent to
| |
| complement | back to summary |
|---|---|
| public RangeSet Returns a view of the complement of this The returned view supports the | |
| contains | back to summary |
|---|---|
| public boolean contains(C value) Determines whether any of this range set's member ranges contains | |
| encloses | back to summary |
|---|---|
| public boolean encloses(Range<C> otherRange) Returns | |
| enclosesAll | back to summary |
|---|---|
| public boolean enclosesAll(RangeSet<C> other) Returns This is equivalent to checking if this range set | |
| enclosesAll | back to summary |
|---|---|
| public default boolean enclosesAll(Iterable<Range<C>> other) Returns This is equivalent to checking if this range set
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Returns
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Returns
| |
| intersects | back to summary |
|---|---|
| public boolean intersects(Range<C> otherRange) Returns
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Returns | |
| rangeContaining | back to summary |
|---|---|
| public Range Returns the unique range from this range set that contains
| |
| remove | back to summary |
|---|---|
| public void remove(Range<C> range) Removes the specified range from this If
| |
| removeAll | back to summary |
|---|---|
| public void removeAll(RangeSet<C> other) Removes all of the ranges from the specified range set from this range set (optional
operation). After this operation, if This is equivalent to calling
| |
| removeAll | back to summary |
|---|---|
| public default void removeAll(Iterable<Range<C>> ranges) Removes all of the specified ranges from this range set (optional operation). This is equivalent to calling
| |
| span | back to summary |
|---|---|
| public Range Returns the minimal range which encloses all ranges in this range set.
| |
| subRangeSet | back to summary |
|---|---|
| public RangeSet Returns a view of the intersection of this The returned view supports all optional operations supported by this | |
| toString | back to summary |
|---|---|
| public String toString() Returns a readable string representation of this range set. For example, if this
| |