if ( iterableSource.supportsOptimizedCursor( interval ) )
return new SubInterval( iterableSource );
}
else if ( transforms.size() == 1 && SlicingTransform.class.isInstance( transforms.get( 0 ) ) )
{
final SlicingTransform t = ( SlicingTransform ) transforms.get( 0 );
final int m = t.numTargetDimensions();
final int n = t.numSourceDimensions();
// Check whether the slicing can be potentially optimized.
boolean optimizable = true;
// 1.) Slice dimensions must be mapped to a contiguous range of
// target dimensions starting with dimension 0.
int firstZeroDim = 0;
for ( ; firstZeroDim < m && !t.getComponentZero( firstZeroDim ); ++firstZeroDim );
for ( int d = firstZeroDim + 1; d < m && optimizable; ++d )
if ( !t.getComponentZero( d ) )
optimizable = false;
// 2.) All slice dimensions must be mapped to a target dimension
final int[] sourceComponent = new int[ n ];
if ( optimizable )
{
Arrays.fill( sourceComponent, -1 );
for ( int d = 0; d < m; ++d )
if ( !t.getComponentZero( d ) )
sourceComponent[ t.getComponentMapping( d ) ] = d;
for ( int d = 0; d < n && optimizable; ++d )
if ( sourceComponent[ d ] < 0 )
optimizable = false;
}
if ( optimizable )
{
// System.out.println( "interval = " + Util.printInterval( interval ) );
final Interval sliceInterval = t.transform( new BoundingBox( interval ) ).getInterval();
// System.out.println( "transformed interval = " + Util.printInterval( sliceInterval ) );
if ( iterableSource.supportsOptimizedCursor( sliceInterval ) )
{
// check for FlatIterationOrder
boolean flat = FlatIterationOrder.class.isInstance( iterableSource.subIntervalIterationOrder( sliceInterval ) );