HiRISE

HiRISE.HiPlan.Utilities
Class IntervalUnion

java.lang.Object
  extended by HiRISE.HiPlan.Utilities.IntervalUnion

public class IntervalUnion
extends Object

An immutable union of one or more closed intervals.

See Also:
Interval

Field Summary
static String ID
          Class identification name with source code version and date.
 
Constructor Summary
IntervalUnion(double[] values)
          Creates a new interval union from an array of values.
IntervalUnion(Interval... intervals)
          Creates a new interval union from a list of intervals.
IntervalUnion(List<Interval> intervals)
          Creates a new interval union from a list of intervals.
 
Method Summary
 boolean contains(double value)
          Determines whether an indicated value is within the union of intervals.
 boolean equals(Object o)
          Indicates whether some other object is "equal to" this one.
 String format(int decimalPlaces)
           
 List<Interval> getIntervals()
          Gets a collection of the individual intervals of this union.
 int hashCode()
          Returns a hash code value for this interval union.
 double[] toArray()
           
 String toString()
          Gets a string representation for this interval union.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values
Constructor Detail

IntervalUnion

public IntervalUnion(List<Interval> intervals)
Creates a new interval union from a list of intervals.

The resulting union has redundant intervals removed, and all remaining, unique intervals are sorted in order of increasing minimum value and secondarily sorted in order of increasing maximum value.

Parameters:
intervals - a list of intervals; may not be null.
Throws:
NullPointerException - if intervals is null or if any element of intervals is null.
IllegalArgumentException - if intervals is empty.

IntervalUnion

public IntervalUnion(Interval... intervals)
Creates a new interval union from a list of intervals.

The resulting union has redundant intervals removed, and all remaining, unique intervals are sorted in order of increasing minimum value and secondarily sorted in order of increasing maximum value.

Parameters:
intervals - a list of intervals; may not be null.
Throws:
NullPointerException - if intervals is null or if any element of intervals is null.
IllegalArgumentException - if intervals is empty.

IntervalUnion

public IntervalUnion(double[] values)
Creates a new interval union from an array of values.

The input array is a collection of min, max value pairs, each pair of which describes an interval. Consequently, values must have an even number of elements.

The resulting union has redundant intervals removed, and all remaining, unique intervals are sorted in order of increasing minimum value and secondarily sorted in order of increasing maximum value.

Parameters:
values - an array of min, max value pairs.
Throws:
NullPointerException - if the array is null.
IllegalArgumentException - if the array is empty or if it contains an odd number of elements, or if any given min is equal to or greater than its matching max.
Method Detail

getIntervals

public List<Interval> getIntervals()
Gets a collection of the individual intervals of this union.

Returns:
a list of this union's intervals.

contains

public boolean contains(double value)
Determines whether an indicated value is within the union of intervals.

If value is contained by any individual interval, the union is said to contain value. Otherwise it does not.

Parameters:
value - the value to be tested.
Returns:
true if any value is within any of the union's closed intervals; false otherwise.
See Also:
Interval.contains(double)

format

public String format(int decimalPlaces)

toArray

public double[] toArray()

toString

public String toString()
Gets a string representation for this interval union. The string is the mathematical representation of a union of closed intervals: [min0,max0] U [min1,max1] U ....

Overrides:
toString in class Object
Returns:
a string representation of this interval union.

hashCode

public int hashCode()
Returns a hash code value for this interval union.

Overrides:
hashCode in class Object
Returns:
a hash code value for this interval union.

equals

public boolean equals(Object o)
Indicates whether some other object is "equal to" this one. An interval union is equal to another if and only the elements of one are equal to the elements of the other.

Overrides:
equals in class Object
Parameters:
o - the object to which this object is compared.
Returns:
true if the objects are equal; false otherwise.
See Also:
Interval.equals(Object)

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona