@Test public void testSumWithCursor() { long sum = 0; final Cursor< IntType > cursor = intImg.cursor(); while ( cursor.hasNext() ) { sum += cursor.next().get(); } assertTrue( sum == intDataSum ); }
@Test public void testJmpWithCursor() { final int steps = 43; final Cursor< IntType > cursor1 = intImg.cursor(); for ( int i = 0; i < steps; ++i ) cursor1.fwd(); final int v1 = cursor1.next().get(); final long[] p1 = new long[ dimensions.length ]; cursor1.localize( p1 ); final Cursor< IntType > cursor2 = intImg.cursor(); cursor2.jumpFwd( steps ); final int v2 = cursor2.next().get(); final long[] p2 = new long[ dimensions.length ]; cursor2.localize( p2 ); assertTrue( v1 == v2 ); assertArrayEquals( p1, p2 ); }
public CellImg<ByteType, ?> generateByteTestCellImg(final boolean fill, final int[] cellDims, final long... dims) { final CellImg<ByteType, ?> img = new CellImgFactory<ByteType>(cellDims) .create(dims, new ByteType()); if (fill) { final Cursor<ByteType> c = img.cursor(); while (c.hasNext()) c.next().set((byte) pseudoRandom()); } return img; }
public CellImg<ByteType, ?> generateByteTestCellImg(final boolean fill, final long... dims) { final CellImg<ByteType, ?> img = new CellImgFactory<ByteType>().create(dims, new ByteType()); if (fill) { final Cursor<ByteType> c = img.cursor(); while (c.hasNext()) c.next().set((byte) pseudoRandom()); } return img; }
@Test public void testResetWithCursor() { final Cursor< IntType > cursor = intImg.cursor(); final int v1 = cursor.next().get(); final long[] p1 = new long[ dimensions.length ]; cursor.localize( p1 ); cursor.reset(); final int v2 = cursor.next().get(); final long[] p2 = new long[ dimensions.length ]; cursor.localize( p2 ); assertTrue( v1 == v2 ); assertArrayEquals( p1, p2 ); }
for ( final Cursor< IntType > c = cellImage.cursor(); c.hasNext(); )
for ( final Cursor< IntType > c = cellImage.cursor(); c.hasNext(); )
for ( final Cursor< IntType > c = cellImage.cursor(); c.hasNext(); )
for ( final Cursor< IntType > c = cellImage.cursor(); c.hasNext(); )