jumbo.euclid
Class IntRange

java.lang.Object
  |
  +--jumbo.euclid.Status
        |
        +--jumbo.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.


Field Summary
protected  int maxval
          maximum of range
protected  int minval
          minimum of range
 
Constructor Summary
IntRange()
          creates invalid range from MAX_VALUE to MIN_VALUE
IntRange(int minv, int maxv)
          initialise with min and max values; if minv > maxv create inValid IntRange
IntRange(IntRange r)
          copy constructor
 
Method Summary
 void add(int x)
          add a value to a range
 boolean contains(int f)
          synonym for includes()
 boolean equals(IntRange r)
          invalid ranges return false
 int getMax()
          get maximum value (MIN_VALUE if inValid)
 int getMin()
          get minimum value (MAX_VALUE if inValid)
 int getRange()
          get range (MIN_VALUE if invalid)
 boolean includes(int f)
          is a int within a IntRange? If inValid, return false
 boolean includes(IntRange r2)
          does one range include another?
 IntRange intersectionWith(IntRange r2)
          intersect two ranges and take the range common to both; return invalid range if no overlap
 boolean isValid()
          a Range is only valid if its maxval is not less than its minval; this tests for uninitialised ranges
static void main(java.lang.String[] args)
          tests IntRange routines
 IntRange plus(IntRange r2)
          combine two ranges if both valid; takes greatest limits of both, else returns InValid
 java.lang.String toString()
          output
 
Methods inherited from class jumbo.euclid.Status
NYI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxval

protected int maxval
maximum of range

minval

protected int minval
minimum of range
Constructor Detail

IntRange

public IntRange()
creates invalid range from MAX_VALUE to MIN_VALUE

IntRange

public IntRange(int minv,
                int maxv)
initialise with min and max values; if minv > maxv create inValid IntRange

IntRange

public IntRange(IntRange r)
copy constructor
Method Detail

isValid

public boolean isValid()
a Range is only valid if its maxval is not less than its minval; this tests for uninitialised ranges

equals

public boolean equals(IntRange r)
invalid ranges return false

plus

public IntRange plus(IntRange r2)
combine two ranges if both valid; takes greatest limits of both, else returns InValid

intersectionWith

public IntRange intersectionWith(IntRange r2)
intersect two ranges and take the range common to both; return invalid range if no overlap

getMin

public int getMin()
get minimum value (MAX_VALUE if inValid)

getMax

public int getMax()
get maximum value (MIN_VALUE if inValid)

getRange

public int getRange()
get range (MIN_VALUE if invalid)

includes

public boolean includes(IntRange r2)
does one range include another?

includes

public boolean includes(int f)
is a int within a IntRange? If inValid, return false

contains

public boolean contains(int f)
synonym for includes()

add

public void add(int x)
add a value to a range

toString

public java.lang.String toString()
output
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
tests IntRange routines