edu.unh.sdb.datasource
Class ISBoundsIterator

java.lang.Object
  extended by edu.unh.sdb.common.Bounds
      extended by edu.unh.sdb.datasource.ISBounds
          extended by edu.unh.sdb.datasource.ISBoundsIterator
All Implemented Interfaces:
SDBIterator, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
BDISBoundsIterator, CellBoundsIterator, DCBoundsIterator

public class ISBoundsIterator
extends ISBounds
implements java.lang.Cloneable, SDBIterator

The ISBoundsIterator class traverses the specified IndexSpace with the specified shape and the specified steps. use the while loop or for loop to traverse:

ISBoundsIterator iter = new ISBoundsIterator(dsBounds, shape, steps);
while (iter.valid()) { System.out.println(iter.toString()); iter.next(); }

or

for(iter.init(); iter.valid(); iter.next()) {
System.out.println(iter.toString()); }

See Also:
Serialized Form

Field Summary
protected  int[] anchor
           
protected  boolean[] fullShape
           
protected  int[] lbounds
           
protected  AxisOrdering ordering
           
protected  int[] shape
           
protected  int[] steps
           
protected  int[] ubounds
           
protected  boolean valid
           
 
Fields inherited from class edu.unh.sdb.datasource.ISBounds
lower, upper
 
Constructor Summary
protected ISBoundsIterator(int d)
           
  ISBoundsIterator(ISBounds space, int[] shape)
          Construct a bounds iterator with no gaps and default AxisOrdering.
  ISBoundsIterator(ISBounds space, int[] shape, AxisOrdering ordering)
          Construct a bounds iterator with no gaps.
  ISBoundsIterator(ISBounds space, int[] shape, int[] gaps)
          Construct a bounds iterator with default AxisOrdering.
  ISBoundsIterator(ISBounds space, int[] shape, int[] gaps, AxisOrdering ordering)
          Construct an ISBoundsIterator that will traverse the given space with an an ISBounds of the given shape (dimensions).
  ISBoundsIterator(ISBounds space, IntegerIndexSpaceID anchor, int[] shape)
          Construct a bounds iterator with specified anchor position, no gaps and default axis axisOrdering.
  ISBoundsIterator(ISBounds space, IntegerIndexSpaceID anchor, int[] shape, AxisOrdering ordering)
          Construct a bounds iterator with specified anchor position and no gaps.
  ISBoundsIterator(ISBounds space, IntegerIndexSpaceID anchor, int[] shape, int[] gaps)
          Construct a bounds iterator with specified anchor position and default axis axisOrdering.
  ISBoundsIterator(ISBounds space, IntegerIndexSpaceID anchor, int[] shape, int[] gaps, AxisOrdering ordering)
          Construct an ISBoundsIterator that will traverse the given space with an an ISBounds of the given shape (dimensions).
  ISBoundsIterator(ISBounds space, ISBounds shape)
          Construct a bounds iterator with no gaps and default AxisOrdering.
  ISBoundsIterator(ISBounds space, ISBounds shape, AxisOrdering ordering)
          Construct a bounds iterator with no gaps.
 
Method Summary
 java.lang.Object clone()
          Return a copy of this ISBoundsIterator
 ISBounds copyBounds()
          Return a simple ISBounds corresponding to the current value of this iterator.
 void end()
          Set the iterator value to the last valid value in the iteration.
 int getAxisLength(int axis)
          Return the length of this iterator's space along the specified axis.
 AxisOrdering getAxisOrdering()
          Return the AxisOrdering object for this iterator.
 IndexSpaceID getBlockShape()
          Return an IndexSpaceID representing the shape of the iterator's blocks.
 AxisOrdering getOrdering()
          Deprecated.  
 ISBounds getSpaceBounds()
          Returns an ISBounds representing the space being iterated over.
 ISBounds getSpaceDimensions()
          Returns an ISBounds representing the shape, but not the position, of the space being iterated over.
 int[] getSpaceDimensionsArray()
          Returns an array of ints representing the dimensions of the space being iterated over.
 IndexSpaceID getSteps()
          Return an IndexSpaceID representing the iterator's steps.
protected  boolean incrementAxis(int axisNumber)
          this is a help fuction for next() function, which is to set a specified value to the specified axis if the value is in bounds
 void init()
          Initialize this ISBoundsIterator
protected  void init(ISBounds bounds)
          this is a help function for constructor, which is to set the Geometric bounds and initial positon of the shape to traverse.
protected  void init(ISBounds bounds, IntegerIndexSpaceID anchor)
           
 boolean isFullShape()
          Return true if the current position defines a bounds that is the full extent of the shape specifed for the Iterator.
static void main(java.lang.String[] args)
          For debugging.
 boolean next()
          Moving the ISBoundsIterator to the next position.
protected  void resetAxis(int axisNumber)
           
 void setBounds(ISBounds spaceBounds)
          Change the bounds of the space that this object iterates over.
protected  void setupAndCheck(int[] shape, int[] gaps)
           
 java.lang.String toString()
          Return a String representing the object.
 java.lang.String toString(java.lang.String indent)
          Return description of this ISBoundsIterator
 boolean valid()
          Return true if the current position is a valid position in the IndexSpace.
 
Methods inherited from class edu.unh.sdb.datasource.ISBounds
boundingVolume, contains, contains, contains, containsExcludeUpper, containsExcludeUpper, copy, copy, copyAndMove, copyAndMove, copyAndMoveCenterTo, copyAndMoveCenterTo, copyAndMoveTo, copyAndMoveTo, copyAndMoveToOrigin, copyExpandBy, copyIncreasedBy, copyLower, copyLower, copyLowerArray, copyLowerArray, copyReducedBy, copyScaled, copyScaled, copyScaled, copyShrinkBy, copyTo, copyTo, copyToOrigin, copyUpper, copyUpper, copyUpperArray, copyUpperArray, createAtOrigin, createAtOrigin, createCentered, createCentered, createCentered, dim, equals, equalShape, equalShapeAfterProject, expand, getDimension, getDimensions, getDimensions, getDimensionsArray, getLower, getLower, getLowerArray, getLowerArray, getUpper, getUpper, getUpperArray, getUpperArray, getVertex, getVertex, hasSameShape, increase, increaseByOne, increaseByOne, intersection, intersects, intersectWith, isSlice, longVolume, makeRelativeTo, makeRelativeTo, move, move, move, moveCenterTo, moveCenterTo, moveTo, moveTo, moveToOrigin, newBoundsAtOrigin, project, reduce, reduceByOne, reduceByOne, set, setAndMove, setAndMoveTo, setLower, setLower, setLower, setToBoundingVolume, setUpper, setUpper, setUpper, slice, split, volume
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ordering

protected AxisOrdering ordering

valid

protected boolean valid

fullShape

protected boolean[] fullShape

shape

protected int[] shape

steps

protected int[] steps

anchor

protected int[] anchor

ubounds

protected int[] ubounds

lbounds

protected int[] lbounds
Constructor Detail

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        int[] shape,
                        int[] gaps,
                        AxisOrdering ordering)
Construct an ISBoundsIterator that will traverse the given space with an an ISBounds of the given shape (dimensions). The last argument specifies the desired gaps between ISBounds in each dimension. A gaps array of all zeros means the generated ISBounds all abut exactly. If a gap value is positive, then there will be that many rows/columns between the generated ISBounds in that dimension. If any of the gaps are negative, then the generated ISBounds will overlap in the corresponding dimension. ( e.g. a gap of -1 means the Bounds will overlap by 1 row/column.) Values in the shape array must be >= 1, and values in the gaps array must allow the iterator to make forward progress. In particular, for negative gap values, the magnitude must be less than the shape value of the same dimension.

Parameters:
space - - space over which iteration is done
shape - - shape of iteration block
gaps - - gaps between blocks (can be negative for overlapping iteration)
axisOrdering - - AxisOrdering for the space

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        int[] shape,
                        int[] gaps)
Construct a bounds iterator with default AxisOrdering.

Parameters:
space - - space over which iteration is done
shape - - shape of iteration block
gaps - - gaps between blocks (can be negative for overlapping iteration)

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        int[] shape)
Construct a bounds iterator with no gaps and default AxisOrdering.

Parameters:
space - - space over which iteration is done
shape - - shape of iteration block

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        ISBounds shape)
Construct a bounds iterator with no gaps and default AxisOrdering.

Parameters:
space - - space over which iteration is done
shape - - shape of iteration block

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        int[] shape,
                        AxisOrdering ordering)
Construct a bounds iterator with no gaps.

Parameters:
space - - space over which iteration is done
shape - - shape of iteration block
axisOrdering - - AxisOrdering for the space

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        ISBounds shape,
                        AxisOrdering ordering)
Construct a bounds iterator with no gaps.

Parameters:
space - - space over which iteration is done
shape - - shape of iteration block
axisOrdering - - AxisOrdering for the space

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        IntegerIndexSpaceID anchor,
                        int[] shape,
                        int[] gaps,
                        AxisOrdering ordering)
Construct an ISBoundsIterator that will traverse the given space with an an ISBounds of the given shape (dimensions). The second argument allows the user to shift the bounds around in the iteration space. Usually, the iteration begins with an ISBounds with a lower bound equal to the lower bound of the iteration space. However, the anchor argument allows the user to offset the partitioning of the iteration space. In particular, the anchor argument specifies a location in the index space that is also the corner points for some set of ISBounds in the partitioning. Notice that this location could be either inside or outside the iteration space. In the event that the anchor location is outside the iteration space, only ISBounds that intersect with the iteration space will be generated by the iteration. In the event that the anchor location is somewhere in the interior of the iteration space, the entire space is still covered by the iteration. Values in the shape array must be >= 1.

Parameters:
space - - space over which iteration is done
anchor - - anchor position of partitioning
shape - - shape of iteration block
gaps - - gaps between blocks (can be negative for overlapping iteration)
axisOrdering - - AxisOrdering for the space

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        IntegerIndexSpaceID anchor,
                        int[] shape)
Construct a bounds iterator with specified anchor position, no gaps and default axis axisOrdering.

Parameters:
space - - space over which iteration is done
anchor - - anchor position of partitioning
shape - - shape of iteration block

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        IntegerIndexSpaceID anchor,
                        int[] shape,
                        AxisOrdering ordering)
Construct a bounds iterator with specified anchor position and no gaps.

Parameters:
space - - space over which iteration is done
anchor - - anchor position of partitioning
shape - - shape of iteration block
axisOrdering - - AxisOrdering for the space

ISBoundsIterator

public ISBoundsIterator(ISBounds space,
                        IntegerIndexSpaceID anchor,
                        int[] shape,
                        int[] gaps)
Construct a bounds iterator with specified anchor position and default axis axisOrdering.

Parameters:
space - - space over which iteration is done
anchor - - anchor position of partitioning
shape - - shape of iteration block
gaps - - gaps between blocks (can be negative for overlapping iteration)

ISBoundsIterator

protected ISBoundsIterator(int d)
Method Detail

setupAndCheck

protected final void setupAndCheck(int[] shape,
                                   int[] gaps)

init

protected void init(ISBounds bounds)
this is a help function for constructor, which is to set the Geometric bounds and initial positon of the shape to traverse.


init

protected void init(ISBounds bounds,
                    IntegerIndexSpaceID anchor)

setBounds

public void setBounds(ISBounds spaceBounds)
Change the bounds of the space that this object iterates over. The iterator is reset to the first iteration value. The gaps between blocks are assumed to be zero.


init

public void init()
Initialize this ISBoundsIterator

Specified by:
init in interface SDBIterator

end

public void end()
Set the iterator value to the last valid value in the iteration.

Specified by:
end in interface SDBIterator

getAxisOrdering

public final AxisOrdering getAxisOrdering()
Return the AxisOrdering object for this iterator.


getOrdering

public final AxisOrdering getOrdering()
Deprecated. 

Return the AxisOrdering object for this iterator.


getAxisLength

public final int getAxisLength(int axis)
Return the length of this iterator's space along the specified axis.


getSpaceBounds

public final ISBounds getSpaceBounds()
Returns an ISBounds representing the space being iterated over.


getSpaceDimensions

public final ISBounds getSpaceDimensions()
Returns an ISBounds representing the shape, but not the position, of the space being iterated over.


getSpaceDimensionsArray

public final int[] getSpaceDimensionsArray()
Returns an array of ints representing the dimensions of the space being iterated over.


getBlockShape

public final IndexSpaceID getBlockShape()
Return an IndexSpaceID representing the shape of the iterator's blocks. This method does not handle the case in which the current iterator value is not a full shape.


getSteps

public final IndexSpaceID getSteps()
Return an IndexSpaceID representing the iterator's steps. A step value for an axis is the distance between corners of consecutive ISBounds.


resetAxis

protected void resetAxis(int axisNumber)

incrementAxis

protected boolean incrementAxis(int axisNumber)
this is a help fuction for next() function, which is to set a specified value to the specified axis if the value is in bounds


valid

public boolean valid()
Return true if the current position is a valid position in the IndexSpace.

Specified by:
valid in interface SDBIterator

isFullShape

public boolean isFullShape()
Return true if the current position defines a bounds that is the full extent of the shape specifed for the Iterator.


next

public boolean next()
Moving the ISBoundsIterator to the next position.

Specified by:
next in interface SDBIterator

copyBounds

public ISBounds copyBounds()
Return a simple ISBounds corresponding to the current value of this iterator.


clone

public java.lang.Object clone()
Return a copy of this ISBoundsIterator

Overrides:
clone in class ISBounds

toString

public java.lang.String toString()
Return a String representing the object.

Overrides:
toString in class ISBounds

toString

public java.lang.String toString(java.lang.String indent)
Return description of this ISBoundsIterator

Overrides:
toString in class ISBounds

main

public static void main(java.lang.String[] args)
For debugging. Runs basic tests on the ISBoundsIterator class.