Package org.jppf.utils
Class Range<T extends Comparable<T>>
java.lang.Object
org.jppf.utils.Range<T>
- Type Parameters:
T- the type of values handled by this object.
Instances of this class represent a range of values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetLower()Get the lower bound.getUpper()Get the upper bound.inthashCode()booleanDetermine whether this range is a superset of the specified other.
More formally, this method returns true ifother.lower >= this.lowerandother.upper <= this.upper.intersection(Range<T> other) Construct aRangethat represents the intersection of this range and the other specified one.
This is equivalent to building a range object with its lower bound equal tomax(this.lower, other.lower)and its upper bound equal tomin(this.upper, other.upper)booleanintersects(Range<T> other) Determine whether this range and the specified one have at least one value in common.booleanintersects(Range<T> other, boolean includeBounds) Determine whether this range and the specified one have at least one value in common.booleanisValueInRange(T value) Determine if the specified value is included in this range.booleanisValueInRange(T value, boolean includeBounds) Determine if the specified value is included in this range.Construct aRangethat is made of all values between the lowest lower bound and the highest upper bound of this range and the other specified range.toString()
-
Constructor Details
-
Range
Initialize this range with the specified single value used as both lower and upper bounds.- Parameters:
value- the value to use for the bounds.
-
Range
Initialize this range with the specified lower and upper bounds.- Parameters:
lower- the lower bound.upper- the upper bound.
-
-
Method Details
-
isValueInRange
Determine if the specified value is included in this range.- Parameters:
value- the value to check.- Returns:
- true if the value is in range, false otherwise.
-
isValueInRange
Determine if the specified value is included in this range.- Parameters:
value- the value to check.includeBounds- specifies whether the bounds of this range shoud be included in the comparisons.- Returns:
- true if the value is in range, false otherwise.
-
toString
-
getLower
Get the lower bound.- Returns:
- the lower bound.
-
getUpper
Get the upper bound.- Returns:
- the upper bound.
-
intersects
Determine whether this range and the specified one have at least one value in common.- Parameters:
other- the range to check against.- Returns:
- true if and only if part of
otheroverlaps this range.
-
intersects
Determine whether this range and the specified one have at least one value in common.- Parameters:
other- the range to check against.includeBounds- specifies whether the bounds of each range shoud be included in the comparisons.- Returns:
- true if and only if part of
otheroverlaps this range.
-
includes
Determine whether this range is a superset of the specified other.
More formally, this method returns true ifother.lower >= this.lowerandother.upper <= this.upper.- Parameters:
other- the range to check against.- Returns:
- true if and only if this range includes all the values from
other.
-
merge
Construct aRangethat 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 ifthis.)intersects(other)== false
This is equivalent to building a range object with its lower bound equal tomin(this.lower, other.lower)and its upper bound equal tomax(this.upper, other.upper)- Parameters:
other- the range to merge with.- Returns:
- a new
Rangeobject 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.
-
intersection
Construct aRangethat represents the intersection of this range and the other specified one.
This is equivalent to building a range object with its lower bound equal tomax(this.lower, other.lower)and its upper bound equal tomin(this.upper, other.upper)- Parameters:
other- the range to check against.- Returns:
- a Range object representing the intersection of 2 ranges, or null if
otheris null or the ranges are disjointed (i.e ifthis.).intersects(other)== false
-
hashCode
public int hashCode() -
equals
-