|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object PIRL.Utilities.Real_Range
public class Real_Range
A Real_Range specifies a range of integer values.
The range of values is characterized by minimum and maximum values that identify the inclusive limits of the range. Single-valued and open-ended ranges are defined. An appropriate String representation is provided.
Field Summary | |
---|---|
static String |
ID
|
protected double |
Maximum
The range maximum value. |
protected double |
Minimum
The range minimum value. |
Constructor Summary | |
---|---|
Real_Range()
Constructs a default Real_Range. |
|
Real_Range(double value)
Constructs a single-valued Real_Range. |
|
Real_Range(double minimum,
double maximum)
Constructs a Real_Range from limiting values. |
|
Real_Range(Integer_Range range)
Constructs a Real_Range from an Integer_Range. |
|
Real_Range(Real_Range range)
Constructs a Real_Range as a copy of another Real_Range. |
Method Summary | |
---|---|
Object |
clone()
Clones this Real_Range. |
double |
Distance()
Gets the distance between the range limits. |
boolean |
equals(Real_Range range)
Compares two Real_Ranges for equality. |
int |
hashCode()
Gets a hash code for this Real_Range. |
boolean |
Is_Open_Ended()
Tests if the Real_Range is open-ended. |
boolean |
Is_Single_Valued()
Tests if the range is for a single value. |
double |
Maximum()
Gets the maximum limit value. |
Real_Range |
Maximum(double maximum)
Sets the maximum range value. |
double |
Minimum()
Gets the minimum range value. |
Real_Range |
Minimum(double minimum)
Sets the minimum range value. |
Real_Range |
Range(double minimum,
double maximum)
Sets the Range minimum and maximum. |
Real_Range |
Range(Integer_Range range)
Sets the range from an Integer_Range. |
Real_Range |
Range(Real_Range range)
Sets the range from another Real_Range. |
String |
toString()
Provides a String representation of the Real_Range. |
Real_Range |
Value(double value)
Sets the range to a single value. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ID
protected double Minimum
protected double Maximum
Constructor Detail |
---|
public Real_Range()
The range values are initialized to zero.
public Real_Range(double minimum, double maximum)
Note: If the minimum is greater than the maximum then it is used as the maximum and the maximum used as the minimum.
minimum
- The minimum inclusive value of the range.maximum
- The maximum inclusive value of the range.Range(double, double)
public Real_Range(double value)
value
- The value of the range.Value(double)
public Real_Range(Real_Range range)
range
- The Real_Range to be copied. If null a default Real_Range
is constructed.Range(Real_Range)
public Real_Range(Integer_Range range)
range
- The Integer_Range to be copied. If null a default
Real_Range is constructed.Range(Integer_Range)
Method Detail |
---|
public Object clone()
clone
in class Object
public Real_Range Range(double minimum, double maximum)
Note: If the minimum is greater than the maximum then it is used as the maximum and the maximum used as the minimum.
minimum
- The minimum inclusive value of the range.maximum
- The maximum inclusive value of the range.
Minimum(double)
,
Maximum(double)
public Real_Range Range(Real_Range range)
N.B.: The values of the source range are copied without checking.
range
- The Real_Range to be copied. If null nothing is done.
public Real_Range Range(Integer_Range range)
Long.MIN_VALUE and Long.MAX_VALUE from the Integer_Range are reset to Double.MIN_VALUE and Double.MAX_VALUE respectively.
range
- The Integer_Range limits.
Minimum(double)
,
Maximum(double)
public double Minimum()
public Real_Range Minimum(double minimum)
If the new minimum value is greater than the current maximum
value, the maximum is reset to the new minimum.
minimum
- The minimum range value.
public double Maximum()
public Real_Range Maximum(double maximum)
If the new maximum rage value is less than the current minimum
value, the minimum is reset to the new maximum.
maximum
- The maximum range value.
public boolean Is_Open_Ended()
minimum
is
Double.MIN_VALUE
or the maximum
is
Double.MAX_VALUE
.public double Distance()
open-ended
.public boolean Is_Single_Valued()
For a single valued range the minimum
and
maximum
values are identical.
public Real_Range Value(double value)
Both the minimum and maximum are set to the value.
value
- The single value for the range.
Minimum(double)
,
Maximum(double)
public boolean equals(Real_Range range)
The two ranges are equal if, and only if, the argument is not null
and the minimum
and maximum
values of the ranges are equal.
public int hashCode()
The result is the upper 16 bits of the hash code of the range minimum as a Double concatenated with the upper 16 bits of the hash code of the range maximum as a Double. That is, the hash code is the value of the expression:
(new Double (Minimum ()).hashCode () & 0xFFFF0000) | (new Double (Maximum ()).hashCode () >>> 16)
hashCode
in class Object
public String toString()
The format of the Integer_Range representation is:
minimum-maximum
If the minimum and maximum are identical then only a single value is represented.
If the minimum is not Double.MIN_VALUE
or the maximum is Double.MAX_VALUE
then the minimum value is represented. Then a dash
('-') delimiter is provided regardless of whether the minimum is
represented or not. If the maximum is not Double.MAX_VALUE
then it is included in the representation after the '-' delimiter.
Note that a range may be open-ended at its minimum or maximum, but
in all cases at least one limit value will be represented with the
minimum value being used if both both limits are open-ended.
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |