xxl.util
Class IntervalND

java.lang.Object
  |
  +--xxl.util.IntervalND

public class IntervalND
extends java.lang.Object
implements java.lang.Cloneable

Class to implement multi-dimensional intervals based on n intervals of class Interval1D.


Field Summary
protected  Interval1D[] intervals
           
 
Constructor Summary
IntervalND(Interval1D[] intervals)
          Constructs a new interval using the given array of one-dimensional intervals.
 
Method Summary
 java.lang.Object clone()
          Clones this interval.
 boolean contains(IntervalND multiDimInterval)
          Checks whether an interval is contained by this interval.
 boolean contains(java.lang.Object[] point)
          Checks whether a point is contained by this interval.
 int dimensions()
          Returns the number of dimensions of this interval.
 boolean equals(java.lang.Object object)
          Returns true iff the given object is a multi-dimensional interval of the same dimension and equal one-dimensional intervals.
 IntervalND intersect(IntervalND multiDimInterval)
          Shrinks this interval to reflect the intersection with a given interval.
 Interval1D[] intervals()
          Returns the internal array of one-dimensional intervals.
 boolean overlaps(IntervalND multiDimInterval)
          Checks whether an interval and this interval do overlap.
 java.lang.String toString()
          Returns a String representation of this interval.
 IntervalND union(IntervalND multiDimInterval)
          Extends this interval to contain a given interval, too.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

intervals

protected Interval1D[] intervals
Constructor Detail

IntervalND

public IntervalND(Interval1D[] intervals)
Constructs a new interval using the given array of one-dimensional intervals.
Method Detail

toString

public java.lang.String toString()
Returns a String representation of this interval.
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
Clones this interval. In particular, all one-dimensional intervals are cloned, too.
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Returns true iff the given object is a multi-dimensional interval of the same dimension and equal one-dimensional intervals.
Overrides:
equals in class java.lang.Object

intervals

public Interval1D[] intervals()
Returns the internal array of one-dimensional intervals.

dimensions

public int dimensions()
Returns the number of dimensions of this interval.

contains

public boolean contains(java.lang.Object[] point)
                 throws java.lang.IllegalArgumentException
Checks whether a point is contained by this interval.
Parameters:
point - The point to be tested.
Returns:
Returns true iff the point is contained by this interval.
Throws:
java.util.IllegalArgumentException - Thrown if the point cannot be tested properly.

contains

public boolean contains(IntervalND multiDimInterval)
                 throws java.lang.IllegalArgumentException
Checks whether an interval is contained by this interval.
Parameters:
multiDimInterval - The interval to be tested.
Returns:
Returns true iff the interval is contained by this interval.
Throws:
java.util.IllegalArgumentException - Thrown if the interval cannot be tested properly.

overlaps

public boolean overlaps(IntervalND multiDimInterval)
                 throws java.lang.IllegalArgumentException
Checks whether an interval and this interval do overlap.
Parameters:
multiDimInterval - The interval to be tested.
Returns:
Returns true iff the interval and this interval do overlap.
Throws:
java.util.IllegalArgumentException - Thrown if the interval cannot be tested properly.

union

public IntervalND union(IntervalND multiDimInterval)
                 throws java.lang.IllegalArgumentException
Extends this interval to contain a given interval, too.
Parameters:
multiDimInterval - The interval which defines the extension of this interval.
Returns:
Returns this interval.
Throws:
java.util.IllegalArgumentException - Thrown if the union cannot be performed properly.

intersect

public IntervalND intersect(IntervalND multiDimInterval)
                     throws java.lang.IllegalArgumentException
Shrinks this interval to reflect the intersection with a given interval.
Parameters:
multiDimInterval - The interval to be intersected with.
Returns:
This interval.
Throws:
java.util.IllegalArgumentException - Thrown if the intersection cannot be performed properly.