T
- the type of values handled by this object.public class Range<T extends Comparable<T>> extends Object
Constructor and Description |
---|
Range(T value)
Initialize this range with the specified single value used as both lower and upper bounds.
|
Range(T lower,
T upper)
Initialize this range with the specified lower and upper bounds.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
T |
getLower()
Get the lower bound.
|
T |
getUpper()
Get the upper bound.
|
int |
hashCode() |
boolean |
includes(Range<T> other)
Determine whether this range is a superset of the specified other.
More formally, this method returns true if other.lower >= this.lower and other.upper <= this.upper . |
Range<T> |
intersection(Range<T> other)
Construct a
Range that represents the intersection of this range and the other specified one.This is equivalent to building a range object with its lower bound equal to max(this.lower, other.lower)
and its upper bound equal to min(this.upper, other.upper) |
boolean |
intersects(Range<T> other)
Determine whether this range and the specified one have at least one value in common.
|
boolean |
intersects(Range<T> other,
boolean includeBounds)
Determine whether this range and the specified one have at least one value in common.
|
boolean |
isValueInRange(T value)
Determine if the specified value is included in this range.
|
boolean |
isValueInRange(T value,
boolean includeBounds)
Determine if the specified value is included in this range.
|
Range<T> |
merge(Range<T> other)
Construct a
Range that is made of all values between the lowest lower bound and the highest upper bound
of this range and the other specified range. |
String |
toString() |
public Range(T value)
value
- the value to use for the bounds.public boolean isValueInRange(T value)
value
- the value to check.public boolean isValueInRange(T value, boolean includeBounds)
value
- the value to check.includeBounds
- specifies whether the bounds of this range shoud be included in the comparisons.public T getLower()
public T getUpper()
public boolean intersects(Range<T> other)
other
- the range to check against.other
overlaps this range.public boolean intersects(Range<T> other, boolean includeBounds)
other
- the range to check against.includeBounds
- specifies whether the bounds of each range shoud be included in the comparisons.other
overlaps this range.public boolean includes(Range<T> other)
other.lower >= this.lower
and other.upper <= this.upper
.other
- the range to check against.other
.public Range<T> merge(Range<T> other)
Range
that is made of all values between the lowest lower bound and the highest upper bound
of this range and the other specified range. This works even if the ranges are completely disjointed
(i.e if this.intersects(other)
== false
)min(this.lower, other.lower)
and its upper bound equal to max(this.upper, other.upper)
other
- the range to merge with.Range
object that encompasses all values between the lowest lower bound and the highest upper bound,
or a copy of this range if the other is null.public Range<T> intersection(Range<T> other)
Range
that represents the intersection of this range and the other specified one.max(this.lower, other.lower)
and its upper bound equal to min(this.upper, other.upper)
other
- the range to check against.other
is null or the ranges are disjointed
(i.e if this.intersects(other)
== false
).Copyright © 2005-2012 JPPF Team.