edu.unh.sdb.datasource
Class BDISBoundsIterator

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

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

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

BDISBoundsIterator iter = new BDISBoundsIterator(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  boolean[] positiveDirection
           
protected  int[] startPoint
           
 
Fields inherited from class edu.unh.sdb.datasource.ISBoundsIterator
anchor, fullShape, lbounds, ordering, shape, steps, ubounds, valid
 
Fields inherited from class edu.unh.sdb.datasource.ISBounds
lower, upper
 
Constructor Summary
protected BDISBoundsIterator(int d)
           
  BDISBoundsIterator(ISBounds space, int[] shape)
          Construct a bounds iterator with no gaps and default AxisOrdering.
  BDISBoundsIterator(ISBounds space, int[] shape, AxisOrdering ordering)
          Construct a bounds iterator with no gaps.
  BDISBoundsIterator(ISBounds space, int[] shape, int[] gaps)
          Construct a bounds iterator with default AxisOrdering.
  BDISBoundsIterator(ISBounds space, int[] shape, int[] gaps, AxisOrdering ordering)
          Construct an BDISBoundsIterator that will traverse the given space with an an ISBounds of the given shape (dimensions).
  BDISBoundsIterator(ISBounds space, IntegerIndexSpaceID anchor, int[] shape)
          Construct a bounds iterator with specified anchor position, no gaps and default axis axisOrdering.
  BDISBoundsIterator(ISBounds space, IntegerIndexSpaceID anchor, int[] shape, AxisOrdering ordering)
          Construct a bounds iterator with specified anchor position and no gaps.
  BDISBoundsIterator(ISBounds space, IntegerIndexSpaceID anchor, int[] shape, int[] gaps)
          Construct a bounds iterator with specified anchor position and default axis axisOrdering.
  BDISBoundsIterator(ISBounds space, IntegerIndexSpaceID anchor, int[] shape, int[] gaps, AxisOrdering ordering)
          Construct an BDISBoundsIterator that will traverse the given space with an an ISBounds of the given shape (dimensions).
  BDISBoundsIterator(ISBounds space, ISBounds shape)
          Construct a bounds iterator with no gaps and default AxisOrdering.
  BDISBoundsIterator(ISBounds space, ISBounds shape, AxisOrdering ordering)
          Construct a bounds iterator with no gaps.
 
Method Summary
protected  void BDsetupAndCheck(int[] shape, int[] gaps)
           
 java.lang.Object clone()
          Return a copy of this BDISBoundsIterator
 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.
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 BDISBoundsIterator
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 BDISBoundsIterator to the next position.
protected  void resetAxis(int axisNumber)
           
 void setBounds(ISBounds spaceBounds)
          Change the bounds of the space that this object iterates over.
 java.lang.String toString()
          Return a String representing the object.
 java.lang.String toString(java.lang.String indent)
          Return description of this BDISBoundsIterator
 boolean valid()
          Return true if the current position is a valid position in the IndexSpace.
 
Methods inherited from class edu.unh.sdb.datasource.ISBoundsIterator
getAxisLength, getAxisOrdering, getBlockShape, getOrdering, getSpaceBounds, getSpaceDimensions, getSpaceDimensionsArray, getSteps, setupAndCheck
 
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

startPoint

protected int[] startPoint

positiveDirection

protected boolean[] positiveDirection
Constructor Detail

BDISBoundsIterator

public BDISBoundsIterator(ISBounds space,
                          int[] shape,
                          int[] gaps,
                          AxisOrdering ordering)
Construct an BDISBoundsIterator 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 iteration

BDISBoundsIterator

public BDISBoundsIterator(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)

BDISBoundsIterator

public BDISBoundsIterator(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

BDISBoundsIterator

public BDISBoundsIterator(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

BDISBoundsIterator

public BDISBoundsIterator(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

BDISBoundsIterator

public BDISBoundsIterator(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

BDISBoundsIterator

public BDISBoundsIterator(ISBounds space,
                          IntegerIndexSpaceID anchor,
                          int[] shape,
                          int[] gaps,
                          AxisOrdering ordering)
Construct an BDISBoundsIterator 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 iteration

BDISBoundsIterator

public BDISBoundsIterator(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

BDISBoundsIterator

public BDISBoundsIterator(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

BDISBoundsIterator

public BDISBoundsIterator(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)

BDISBoundsIterator

protected BDISBoundsIterator(int d)
Method Detail

BDsetupAndCheck

protected final void BDsetupAndCheck(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.

Overrides:
init in class ISBoundsIterator

init

protected void init(ISBounds bounds,
                    IntegerIndexSpaceID anchor)
Overrides:
init in class ISBoundsIterator

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 unchanged.

Overrides:
setBounds in class ISBoundsIterator

init

public void init()
Initialize this BDISBoundsIterator

Specified by:
init in interface SDBIterator
Overrides:
init in class ISBoundsIterator

end

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

Specified by:
end in interface SDBIterator
Overrides:
end in class ISBoundsIterator

resetAxis

protected void resetAxis(int axisNumber)
Overrides:
resetAxis in class ISBoundsIterator

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

Overrides:
incrementAxis in class ISBoundsIterator

valid

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

Specified by:
valid in interface SDBIterator
Overrides:
valid in class ISBoundsIterator

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.

Overrides:
isFullShape in class ISBoundsIterator

next

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

Specified by:
next in interface SDBIterator
Overrides:
next in class ISBoundsIterator

copyBounds

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

Overrides:
copyBounds in class ISBoundsIterator

clone

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

Overrides:
clone in class ISBoundsIterator

toString

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

Overrides:
toString in class ISBoundsIterator

toString

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

Overrides:
toString in class ISBoundsIterator

main

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