@Override public CellLocalizingCursor< T, C > localizingCursor() { return new CellLocalizingCursor<>( this ); }
@Override public CellLocalizingCursor< T, C > copyCursor() { return copy(); }
@Override public void fwd() { if ( ++index > lastIndexInCell ) { moveToNextCell(); index = 0; } type.updateIndex( index ); for ( int d = 0; d < n; ++d ) { if ( ++position[ d ] > currentCellMax[ d ] ) position[ d ] = currentCellMin[ d ]; else break; } }
@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 ); } final C cell = getCell(); currentCellMin = cell.min; currentCellMax = cell.max; index = ( int ) newIndex; cell.indexToGlobalPosition( index, position ); type.updateIndex( index ); type.updateContainer( this ); }
public CellLocalizingCursor( final AbstractCellImg< T, ?, C, ? > img ) { super( img.numDimensions() ); this.type = img.createLinkedType(); this.cursorOnCells = img.getCells().cursor(); this.currentCellMin = null; this.currentCellMax = null; reset(); }
protected CellLocalizingCursor( final CellLocalizingCursor< T, C > cursor ) { super( cursor.numDimensions() ); this.type = cursor.type.duplicateTypeOnSameNativeImg(); this.cursorOnCells = cursor.cursorOnCells.copyCursor(); this.currentCellMin = cursor.currentCellMin; this.currentCellMax = cursor.currentCellMax; isNotLastCell = cursor.isNotLastCell; lastIndexInCell = cursor.lastIndexInCell; for ( int d = 0; d < n; ++d ) position[ d ] = cursor.position[ d ]; index = cursor.index; type.updateContainer( this ); type.updateIndex( index ); }
@Override public void fwd() { if ( ++index > lastIndexInCell ) { moveToNextCell(); index = 0; } type.updateIndex( index ); for ( int d = 0; d < n; ++d ) { if ( ++position[ d ] > currentCellMax[ d ] ) position[ d ] = currentCellMin[ d ]; else break; } }
@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 ); } final C cell = getCell(); currentCellMin = cell.min; currentCellMax = cell.max; index = ( int ) newIndex; cell.indexToGlobalPosition( index, position ); type.updateIndex( index ); type.updateContainer( this ); }
public CellLocalizingCursor( final AbstractCellImg< T, ?, C, ? > img ) { super( img.numDimensions() ); this.type = img.createLinkedType(); this.cursorOnCells = img.getCells().cursor(); this.currentCellMin = null; this.currentCellMax = null; reset(); }
protected CellLocalizingCursor( final CellLocalizingCursor< T, C > cursor ) { super( cursor.numDimensions() ); this.type = cursor.type.duplicateTypeOnSameNativeImg(); this.cursorOnCells = cursor.cursorOnCells.copyCursor(); this.currentCellMin = cursor.currentCellMin; this.currentCellMax = cursor.currentCellMax; isNotLastCell = cursor.isNotLastCell; lastIndexInCell = cursor.lastIndexInCell; for ( int d = 0; d < n; ++d ) position[ d ] = cursor.position[ d ]; index = cursor.index; type.updateContainer( this ); type.updateIndex( index ); }
@Override public void reset() { cursorOnCells.reset(); moveToNextCell(); index = -1; type.updateIndex( index ); }
@Override public CellLocalizingCursor< T, C > copy() { return new CellLocalizingCursor<>( this ); }
/** * Move cursor right before the first element of the next cell. Update type, * position, and index variables. */ private void moveToNextCell() { cursorOnCells.fwd(); isNotLastCell = cursorOnCells.hasNext(); final C cell = getCell(); lastIndexInCell = ( int ) ( cell.size() - 1 ); currentCellMin = cell.min; currentCellMax = cell.max; position[ 0 ] = currentCellMin[ 0 ] - 1; for ( int d = 1; d < n; ++d ) position[ d ] = currentCellMin[ d ]; type.updateContainer( this ); } }
@Override public CellLocalizingCursor< T, C > copyCursor() { return copy(); }
@Override public void reset() { cursorOnCells.reset(); moveToNextCell(); index = -1; type.updateIndex( index ); }
@Override public CellLocalizingCursor< T, C > localizingCursor() { return new CellLocalizingCursor<>( this ); }
/** * Move cursor right before the first element of the next cell. Update type, * position, and index variables. */ private void moveToNextCell() { cursorOnCells.fwd(); isNotLastCell = cursorOnCells.hasNext(); final C cell = getCell(); lastIndexInCell = ( int ) ( cell.size() - 1 ); currentCellMin = cell.min; currentCellMax = cell.max; position[ 0 ] = currentCellMin[ 0 ] - 1; for ( int d = 1; d < n; ++d ) position[ d ] = currentCellMin[ d ]; type.updateContainer( this ); } }
@Override public CellLocalizingCursor< T, C > copy() { return new CellLocalizingCursor<>( this ); }