Example #1
0
 /**
  * Move cursor right before the first element of the next cell. Update type and index variables.
  */
 private void moveToNextCell() {
   cursorOnCells.fwd();
   isNotLastCell = cursorOnCells.hasNext();
   lastIndexInCell = (int) (getCell().size() - 1);
   index = -1;
   type.updateContainer(this);
 }
Example #2
0
  protected ArrayCursor(final ArrayCursor<T> cursor) {
    super(cursor.numDimensions());

    this.container = cursor.container;
    this.type = container.createLinkedType();
    this.lastIndex = (int) container.size() - 1;

    type.updateIndex(cursor.type.getIndex());
    type.updateContainer(this);
  }
Example #3
0
  public ArrayRandomAccess(final ArrayImg<T, ?> container) {
    super(container.numDimensions());

    this.img = container;
    this.type = container.createLinkedType();

    for (int d = 0; d < n; d++) position[d] = 0;

    type.updateContainer(this);
    type.updateIndex(0);
  }
Example #4
0
  protected CellCursor(final CellCursor<T, A, C> cursor) {
    super(cursor.numDimensions());

    this.type = cursor.type.duplicateTypeOnSameNativeImg();
    this.cursorOnCells = cursor.cursorOnCells.copyCursor();
    isNotLastCell = cursor.isNotLastCell;
    lastIndexInCell = cursor.lastIndexInCell;
    index = cursor.index;

    type.updateContainer(this);
    type.updateIndex(index);
  }
Example #5
0
 @Override
 public void jumpFwd(final long steps) {
   long newIndex = index + steps;
   while (newIndex > lastIndexInCell) {
     newIndex -= lastIndexInCell + 1;
     cursorOnCells.fwd();
     isNotLastCell = cursorOnCells.hasNext();
     lastIndexInCell = (int) (getCell().size() - 1);
   }
   index = (int) newIndex;
   type.updateIndex(index);
   type.updateContainer(this);
 }
Example #6
0
  protected ArrayRandomAccess(final ArrayRandomAccess<T> randomAccess) {
    super(randomAccess.numDimensions());

    this.img = randomAccess.img;
    this.type = img.createLinkedType();

    int index = 0;
    for (int d = 0; d < n; d++) {
      position[d] = randomAccess.position[d];
      index += position[d] * img.steps[d];
    }

    type.updateContainer(this);
    type.updateIndex(index);
  }
Example #7
0
 @Override
 public void reset() {
   type.updateIndex(-1);
   type.updateContainer(this);
 }