@Override public long getLongPosition( final int dim ) { return getCell().indexToGlobalPosition( index, dim ); }
@Override public long getLongPosition( final int dim ) { return getCell().indexToGlobalPosition( index, dim ); }
@Override public void localize( final long[] position ) { getCell().indexToGlobalPosition( index, position ); }
@Override public void localize( final long[] position ) { getCell().indexToGlobalPosition( index, position ); }
@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 ); }
@Test public void testGlobalPositionCalculation() { final Cell< FloatArray > cell = new Cell<>( new int[] {20, 8, 10}, new long[] { 0, 9876543210l, 222 }, new FloatArray( 1 ) ); final int[] index = { 883, 492, 43 }; final long[][] expectedPosition = { { 3, 9876543214l, 227 }, { 12, 9876543210l, 225 }, { 3, 9876543212l, 222 } }; for ( int i = 0; i < index.length; ++i ) { final long[] position = new long[ 3 ]; cell.indexToGlobalPosition( index[ i ], position ); assertArrayEquals( expectedPosition[ i ], position ); for ( int d = 0; d < position.length; ++d ) assertTrue( cell.indexToGlobalPosition( index[ i ], d ) == expectedPosition[ i ][ d ] ); } } }
@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 ); }