gov.sns.tools.math
Class Interval

java.lang.Object
  |
  +--gov.sns.tools.math.Interval
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ClosedInterval, OpenInterval

public class Interval
extends java.lang.Object
implements java.io.Serializable

Represents an interval on the real line. Issues concerning boundary points are delegated to the derived classes OpenInterval and ClosedInterval.

See Also:
Serialized Form

Constructor Summary
Interval()
          Default constructor - creates a new instance of Interval with one point, the origin.
Interval(double min, double max)
          Initializing constructor - create an interval with specified endpoints
Interval(Interval I)
          Copy constructor - create a new open interval initialized to the argument.
 
Method Summary
 boolean boundary(double x)
          Is point a boundary element
 Interval computeHull(Interval I)
          Compute and return the smallest interval containing both this interval and the argument interval.
 boolean equals(Interval I)
          Are intervals equal
 double getMax()
          Get maximum value of interval.
 double getMin()
          Get minimum value of interval.
 double measure()
          Compute the interval length
 double midpoint()
          Compute the interval midpoint
 void print(java.io.PrintWriter os)
          Print out contents on an output stream
 void println(java.io.PrintWriter os)
          Print out contents on an output stream, terminate in newline character
 void setMax(double max)
          Set the right endpoint
 void setMin(double min)
          Set the left endpoint
 java.lang.String toString()
          Return the contents of the interval as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Interval

public Interval()
Default constructor - creates a new instance of Interval with one point, the origin.


Interval

public Interval(double min,
                double max)
Initializing constructor - create an interval with specified endpoints

Parameters:
min - left endpoint
max - right endpoint

Interval

public Interval(Interval I)
Copy constructor - create a new open interval initialized to the argument.

Parameters:
I - interval to copy
Method Detail

setMin

public void setMin(double min)
Set the left endpoint


setMax

public void setMax(double max)
Set the right endpoint


getMin

public double getMin()
Get minimum value of interval.


getMax

public double getMax()
Get maximum value of interval.


measure

public double measure()
Compute the interval length


midpoint

public double midpoint()
Compute the interval midpoint


computeHull

public Interval computeHull(Interval I)
Compute and return the smallest interval containing both this interval and the argument interval.

Parameters:
I - argument
Returns:
convex hull of this and I

boundary

public boolean boundary(double x)
Is point a boundary element

Parameters:
x - point to be tested as boundary element
Returns:
true if x is a boundary element

equals

public boolean equals(Interval I)
Are intervals equal

Parameters:
I - interval object to be checked for equality
Returns:
true if both objects are equal as intervals

toString

public java.lang.String toString()
Return the contents of the interval as a String. return string representation of interval

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

print

public void print(java.io.PrintWriter os)
Print out contents on an output stream

Parameters:
os - output stream receiving content dump

println

public void println(java.io.PrintWriter os)
Print out contents on an output stream, terminate in newline character

Parameters:
os - output stream receiving content dump