public class IntTreeRangeSet
extends java.lang.Object
IntRangeSet
backed by a TreeMap
.Modifier and Type | Method and Description |
---|---|
void |
add(IntRange rangeToAdd)
Adds the specified range to this
IntRangeSet (optional operation). |
void |
addAll(IntRangeSet other)
Adds all of the ranges from the specified range set to this range set (optional operation).
|
java.util.Set<IntRange> |
asRanges()
Returns a view of the disconnected ranges that make up this
range set.
|
void |
clear()
Removes all ranges from this
IntRangeSet (optional operation). |
IntRangeSet |
complement()
Returns a view of the complement of this
IntRangeSet . |
boolean |
contains(int value)
Determines whether any of this range set's member ranges contains
value . |
static IntTreeRangeSet |
create()
Creates an empty
IntTreeRangeSet instance. |
static IntTreeRangeSet |
create(IntRangeSet rangeSet)
Returns a
IntTreeRangeSet initialized with the ranges in the specified range set. |
boolean |
encloses(IntRange range)
Returns
true if there exists a member range in this range set which
encloses the specified range. |
boolean |
enclosesAll(IntRangeSet other)
Returns
true if for each member range in other there exists a member range in
this range set which encloses it. |
boolean |
equals(java.lang.Object obj)
Returns
true if obj is another IntRangeSet that contains the same ranges
according to IntRange.equals(Object) . |
int |
hashCode()
Returns
asRanges().hashCode() . |
boolean |
intersects(IntRange otherRange)
Returns
true if there exists a non-empty range enclosed by both a member range in this
range set and the specified range. |
boolean |
isEmpty()
Returns
true if this range set contains no ranges. |
IntRange |
rangeContaining(int value)
Returns the unique range from this range set that contains
value , or null if this range set does not contain value . |
void |
remove(IntRange rangeToRemove)
Removes the specified range from this
IntRangeSet (optional operation). |
void |
removeAll(IntRangeSet other)
Removes all of the ranges from the specified range set from this range set (optional
operation).
|
IntRange |
span()
Returns the minimal range which encloses all ranges
in this range set.
|
IntRangeSet |
subRangeSet(IntRange view)
Returns a view of the intersection of this
IntRangeSet with the specified range. |
java.lang.String |
toString()
Returns a readable string representation of this range set.
|
public static IntTreeRangeSet create()
IntTreeRangeSet
instance.public static IntTreeRangeSet create(IntRangeSet rangeSet)
IntTreeRangeSet
initialized with the ranges in the specified range set.public java.util.Set<IntRange> asRanges()
IntRangeSet
Iterable.iterator()
method return the ranges in increasing order of lower bound
(equivalently, of upper bound).@Nullable public IntRange rangeContaining(int value)
IntRangeSet
value
, or null
if this range set does not contain value
.rangeContaining
in interface IntRangeSet
public boolean encloses(IntRange range)
IntRangeSet
true
if there exists a member range in this range set which
encloses the specified range.encloses
in interface IntRangeSet
public IntRange span()
IntRangeSet
public void add(IntRange rangeToAdd)
IntRangeSet
IntRangeSet
(optional operation). That is, for equal
range sets a and b, the result of a.add(range)
is that a
will be the minimal
range set for which both a.enclosesAll(b)
and a.encloses(range)
.
Note that range
will be coalesced with any ranges in
the range set that are connected with it. Moreover,
if range
is empty, this is a no-op.
add
in interface IntRangeSet
public void remove(IntRange rangeToRemove)
IntRangeSet
IntRangeSet
(optional operation). After this
operation, if range.contains(c)
, this.contains(c)
will return false
.
If range
is empty, this is a no-op.
remove
in interface IntRangeSet
public IntRangeSet complement()
IntRangeSet
IntRangeSet
.
The returned view supports the IntRangeSet.add(org.datavec.dataframe.util.collections.IntRange)
operation if this IntRangeSet
supports
IntRangeSet.remove(org.datavec.dataframe.util.collections.IntRange)
, and vice versa.
public IntRangeSet subRangeSet(IntRange view)
IntRangeSet
public boolean contains(int value)
IntRangeSet
value
.contains
in interface IntRangeSet
public boolean isEmpty()
IntRangeSet
true
if this range set contains no ranges.isEmpty
in interface IntRangeSet
public void clear()
IntRangeSet
IntRangeSet
(optional operation). After this operation,
this.contains(c)
will return false for all c
.
This is equivalent to remove(IntRange.all())
.
clear
in interface IntRangeSet
public boolean enclosesAll(IntRangeSet other)
IntRangeSet
true
if for each member range in other
there exists a member range in
this range set which encloses it. It follows that
this.contains(value)
whenever other.contains(value)
. Returns true
if
other
is empty.
This is equivalent to checking if this range set IntRangeSet.encloses(org.datavec.dataframe.util.collections.IntRange)
each of the ranges in
other
.
enclosesAll
in interface IntRangeSet
public void addAll(IntRangeSet other)
IntRangeSet
other
.
This is equivalent to calling IntRangeSet.add(org.datavec.dataframe.util.collections.IntRange)
on each of the ranges in other
in turn.
addAll
in interface IntRangeSet
public void removeAll(IntRangeSet other)
IntRangeSet
other.contains(c)
, this.contains(c)
will
return false
.
This is equivalent to calling IntRangeSet.remove(org.datavec.dataframe.util.collections.IntRange)
on each of the ranges in other
in
turn.
removeAll
in interface IntRangeSet
public boolean intersects(IntRange otherRange)
IntRangeSet
true
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 calling
subRangeSet(otherRange)
and testing whether the resulting range set is non-empty.intersects
in interface IntRangeSet
public boolean equals(@Nullable java.lang.Object obj)
IntRangeSet
true
if obj
is another IntRangeSet
that contains the same ranges
according to IntRange.equals(Object)
.equals
in interface IntRangeSet
equals
in class java.lang.Object
public final int hashCode()
IntRangeSet
asRanges().hashCode()
.hashCode
in interface IntRangeSet
hashCode
in class java.lang.Object
public final java.lang.String toString()
IntRangeSet
IntRangeSet
consisted of IntRange.closed(1, 3)
and IntRange.greaterThan(4)
,
this might return " [1..3](4..+∞)
"}.toString
in interface IntRangeSet
toString
in class java.lang.Object