Class pmr.euclid.IntRange
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pmr.euclid.IntRange

java.lang.Object
   |
   +----pmr.euclid.Status
           |
           +----pmr.euclid.IntRange

public class IntRange
extends Status
IntRange - maximum and minimum values

Contains two ints representing the minimum and maximum of an allowed or observed range.

Default is range with low > high; this can be regarded as the uninitialised state. If points are added to a default IntRange it becomes initialised.

Author:
(C) P. Murray-Rust, 1996

Variable Index

 o maxval
maximum of range
 o minval
minimum of range

Constructor Index

 o IntRange()
creates invalid range from MAX_VALUE to MIN_VALUE
 o IntRange(int, int)
initialise with min and max values; if minv > maxv create inValid IntRange
 o IntRange(IntRange)
copy constructor

Method Index

 o add(int)
add a value to a range
 o contains(int)
synonym for includes()
 o equals(IntRange)
invalid ranges return false
 o getMax()
get maximum value (MIN_VALUE if inValid)
 o getMin()
get minimum value (MAX_VALUE if inValid)
 o getRange()
get range (MIN_VALUE if invalid)
 o includes(int)
is a int within a IntRange? If inValid, return false
 o includes(IntRange)
does one range include another?
 o intersectionWith(IntRange)
intersect two ranges and take the range common to both; return invalid range if no overlap
 o isValid()
a Range is only valid if its maxval is not less than its minval; this tests for uninitialised ranges
 o main(String[])
tests IntRange routines
 o plus(IntRange)
combine two ranges if both valid; takes greatest limits of both, else returns InValid
 o toString()
output

Variables

 o maxval
  protected int maxval
maximum of range
 o minval
  protected int minval
minimum of range

Constructors

 o IntRange
  public IntRange()
creates invalid range from MAX_VALUE to MIN_VALUE
 o IntRange
  public IntRange(int minv,
                  int maxv)
initialise with min and max values; if minv > maxv create inValid IntRange
 o IntRange
  public IntRange(IntRange r)
copy constructor

Methods

 o isValid
  public boolean isValid()
a Range is only valid if its maxval is not less than its minval; this tests for uninitialised ranges
 o equals
  public boolean equals(IntRange r)
invalid ranges return false
 o plus
  public IntRange plus(IntRange r2)
combine two ranges if both valid; takes greatest limits of both, else returns InValid
 o intersectionWith
  public IntRange intersectionWith(IntRange r2)
intersect two ranges and take the range common to both; return invalid range if no overlap
 o getMin
  public int getMin()
get minimum value (MAX_VALUE if inValid)
 o getMax
  public int getMax()
get maximum value (MIN_VALUE if inValid)
 o getRange
  public int getRange()
get range (MIN_VALUE if invalid)
 o includes
  public boolean includes(IntRange r2)
does one range include another?
 o includes
  public boolean includes(int f)
is a int within a IntRange? If inValid, return false
 o contains
  public boolean contains(int f)
synonym for includes()
 o add
  public void add(int x)
add a value to a range
 o toString
  public String toString()
output
Overrides:
toString in class Object
 o main
  public static void main(String args[])
tests IntRange routines

All Packages  Class Hierarchy  This Package  Previous  Next  Index