|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.tum.cs.commons.math.Range
public class Range
A class that represents ranges that may include or exclude the upper and lower bounds. This class is immutable.
Note: If a range is constructed where the upper and lower bounds are equal and one of them is exclusive, this range is considered empty, i.e. no number can be contained in it.
Constructor Summary | |
---|---|
Range(double lower,
boolean lowerIsInclusive,
double upper,
boolean upperIsInclusive)
Create range. |
|
Range(double lower,
double upper)
Create range where both bounds are inclusive. |
Method Summary | |
---|---|
boolean |
contains(double number)
Checks is a number is contained in the range. |
boolean |
equals(java.lang.Object obj)
Two ranges are equal if their bounds are equal and the flags that indicate if the bounds are inclusive or not are equal, too. |
java.lang.String |
format(java.text.NumberFormat numberFormat)
String representation contains the bounds and brackets that indicate if the bounds are inclusive or exclusive. |
double |
getLower()
Get lower bound. |
double |
getUpper()
Get upper bound. |
int |
hashCode()
Hash code includes bound and the flags that indicate if the bounds are inclusive or not. |
boolean |
isEmpty()
Checks if a range is empty. |
boolean |
isLowerInclusive()
Get flag that indicates if the lower bound is inclusive. |
boolean |
isUpperInclusive()
Get flag that indicates if the upper bound is inclusive. |
double |
size()
Returns the size of the range. |
java.lang.String |
toString()
This forwards to format(null); . |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Range(double lower, double upper)
public Range(double lower, boolean lowerIsInclusive, double upper, boolean upperIsInclusive)
lower
- lower boundlowerIsInclusive
- flag that indicates if lower bound is inclusive or notupper
- upper boundupperIsInclusive
- flag that indicates if upper bound is inclusive or notMethod Detail |
---|
public boolean contains(double number)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public double getLower()
public double getUpper()
public boolean isLowerInclusive()
public boolean isUpperInclusive()
public boolean isEmpty()
public double size()
public java.lang.String toString()
format(null);
.
toString
in class java.lang.Object
public java.lang.String format(java.text.NumberFormat numberFormat)
numberFormat
- number format used for formatting the numbers. If this is
null
, no special formatting is applied.
|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |