@Override public void setPosition(final Localizable localizable) { localizable.localize(position); int index = 0; for (int d = 0; d < n; ++d) index += position[d] * img.steps[d]; type.updateIndex(index); }
@Override public void fwd() { if (++index > lastIndexInCell) { moveToNextCell(); index = 0; } type.updateIndex(index); }
@Override public void setPosition(final int[] pos) { int index = 0; for (int d = 0; d < n; ++d) { position[d] = pos[d]; index += pos[d] * img.steps[d]; } type.updateIndex(index); }
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); }
@Override public void setPosition(final long[] pos) { int index = 0; for (int d = 0; d < n; ++d) { final int p = (int) pos[d]; position[d] = p; index += p * img.steps[d]; } type.updateIndex(index); }
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); }
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); }
@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); }
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); }
@Override public void reset() { type.updateIndex(-1); type.updateContainer(this); }
@Override public void reset() { cursorOnCells.reset(); moveToNextCell(); type.updateIndex(index); }
/** * Sets the {@link ArrayRandomAccess} to a certain position in dimension 0 * * <p>Careful: it assumes that it is only a one-dimensional image, all other dimensions would be * set to zero (this saves one subtraction) * * @param pos - the new position */ public void setPositionDim0(final long pos) { type.updateIndex((int) pos); position[0] = (int) pos; }
/** * Sets the {@link ArrayRandomAccess} to a certain position in dimension 0 * * <p>Careful: it assumes that it is only a one-dimensional image, all other dimensions would be * set to zero (this saves one subtraction) * * @param pos - the new position */ public void setPositionDim0(final int pos) { type.updateIndex(pos); position[0] = pos; }