public final class IntegerRange
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
IntegerRange.RangePointType
This enumeration contains types of range bounds.
|
| Constructor and Description |
|---|
IntegerRange(java.math.BigInteger value)
Constructs a single-value range.
|
IntegerRange(java.math.BigInteger min,
java.math.BigInteger max)
Constructs a range with the given lower (
min) and upper (max) bounds. |
IntegerRange(long value)
Constructs a single-value range.
|
IntegerRange(long min,
long max)
Constructs a range with the given lower (
min) and upper (max) bounds. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(java.math.BigInteger value)
Checks whether this range contains the given point.
|
boolean |
contains(IntegerRange rhs)
Checks whether this range contains (as a subset) the given one (
rhs). |
static java.util.List<IntegerRange> |
divide(java.util.Collection<IntegerRange> ranges)
Transforms the collection of ranges to the list of disjoint ranges.
|
boolean |
equals(java.lang.Object o) |
java.math.BigInteger |
getMax()
Returns the upper bound of the range.
|
java.math.BigInteger |
getMin()
Returns the lower bound of the range.
|
int |
hashCode() |
IntegerRange |
intersect(IntegerRange rhs)
Returns the intersection of this range with the given one.
|
boolean |
isSingular()
Checks whether the range is singular (consists of a single value:
min == max). |
IntegerRange |
merge(IntegerRange rhs)
Returns the union of this range with the given one.
|
java.util.List<IntegerRange> |
minus(IntegerRange rhs)
Returns the list of ranges representing the difference between this range and the given one.
|
boolean |
overlaps(IntegerRange rhs)
Checks whether this range overlaps with the given one (
rhs). |
static java.util.Collection<IntegerRange> |
select(java.util.Collection<IntegerRange> ranges,
IntegerRange bounds)
Selects all ranges from the the given collection that are within the given bounds.
|
void |
setMax(java.math.BigInteger max)
Sets the upper bound of the range.
|
void |
setMin(java.math.BigInteger min)
Sets the lower bound of the range.
|
IntegerRange |
shift(int value)
Returns the shifted variant of this range (
[min + value, max + value]). |
java.math.BigInteger |
size()
Returns the size of the range.
|
java.lang.String |
toString() |
java.util.List<IntegerRange> |
union(IntegerRange rhs)
Returns the list of ranges representing the union of this range with the given one.
|
public IntegerRange(java.math.BigInteger min,
java.math.BigInteger max)
min) and upper (max) bounds.min - the lower bound of the range.max - the upper bound of the range.java.lang.IllegalArgumentException - if min or max is null.java.lang.IllegalArgumentException - if (min > max).public IntegerRange(java.math.BigInteger value)
value - the only value of the range.public IntegerRange(long min,
long max)
min) and upper (max) bounds.min - the lower bound of the range.max - the upper bound of the range.public IntegerRange(long value)
value - the only value of the range.public static java.util.List<IntegerRange> divide(java.util.Collection<IntegerRange> ranges)
ranges - the collection of ranges.java.lang.IllegalArgumentException - if ranges is null.public static java.util.Collection<IntegerRange> select(java.util.Collection<IntegerRange> ranges, IntegerRange bounds)
ranges - the collection of ranges.bounds - the bounds.java.lang.IllegalArgumentException - if some of the parameters are null.public java.math.BigInteger getMin()
public void setMin(java.math.BigInteger min)
min - the lower bound to be set.java.lang.IllegalArgumentException - if max is null or (min > max).public java.math.BigInteger getMax()
public void setMax(java.math.BigInteger max)
max - the upper bound to be set.java.lang.IllegalArgumentException - if max is null or (min > max).public java.math.BigInteger size()
public boolean isSingular()
min == max).true if the range is singular; false otherwise.public boolean overlaps(IntegerRange rhs)
rhs).rhs - the range to be compared with this one.true if this range overlaps with the given one; false otherwise.java.lang.IllegalArgumentException - if rhs is null.public boolean contains(IntegerRange rhs)
rhs).rhs - the range to be compared with this one.true if this range contains the given one; false otherwise.java.lang.IllegalArgumentException - if rhs is null.public boolean contains(java.math.BigInteger value)
value - the point.true if this range contains the given point; false otherwise.java.lang.IllegalArgumentException - if value is null.public IntegerRange shift(int value)
[min + value, max + value]).value - the shift value.public IntegerRange intersect(IntegerRange rhs)
null.rhs - the range to be intersected with this one.null if the ranges are disjoint.java.lang.IllegalArgumentException - if rhs is null.public IntegerRange merge(IntegerRange rhs)
null.rhs - the range to be merged with this one.null if the ranges are disjoint.java.lang.IllegalArgumentException - if rhs is null.public java.util.List<IntegerRange> union(IntegerRange rhs)
merge(rhs));
otherwise, it includes two ranges: this and rhs.rhs - the range to be united with this one.java.lang.IllegalArgumentException - if rhs is null.public java.util.List<IntegerRange> minus(IntegerRange rhs)
rhs - the range to be subtracted from this one.java.lang.IllegalArgumentException - if rhs is null.public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object