@Override final public E[] nextChunk() { return src.nextChunk(); }
@Override public E[] next() { return src.nextChunk(); }
@Override final public E[] nextChunk() { return src.nextChunk(); }
@Override public E[] next() { return src.nextChunk(); }
@SuppressWarnings("unchecked") public E next() { if (!hasNext()) throw new NoSuchElementException(); return (E) src.nextChunk(); }
@Override public E[] next() { if (!hasNext()) throw new NoSuchElementException(); return src.nextChunk(); }
@SuppressWarnings("unchecked") public E next() { if (!hasNext()) throw new NoSuchElementException(); return (E) src.nextChunk(); }
@Override public E[] next() { if (!hasNext()) throw new NoSuchElementException(); return src.nextChunk(); }
public boolean hasNext() { while ((chunk == null || index == chunk.length) && src.hasNext()) { // fetch and filter another chunk. chunk = filter.filterChunk(src.nextChunk()); // reset the index into the current chunk. index = 0; } if (chunk == null || index == chunk.length) { // nothing left. return false; } return true; }
public boolean hasNext() { while ((chunk == null || index == chunk.length) && src.hasNext()) { // fetch and filter another chunk. chunk = filter.filterChunk(src.nextChunk()); // reset the index into the current chunk. index = 0; } if (chunk == null || index == chunk.length) { // nothing left. return false; } return true; }
public void test_filter() { final IChunkedIterator<Long> actual = (IChunkedIterator<Long>) new ChunkedStriterator<IChunkedIterator<Long>, Long>( Arrays.asList(new Long[] { 1L, 3L, 5L }).iterator()) .addFilter(new Appender<IChunkedIterator<Long>, Long>( new ChunkedWrappedIterator<Long>(Arrays.asList( new Long[] { 2L, 3L, 4L }).iterator()))); assertEquals(new Long[] { // 1L, 3L, 5L, // src1 2L, 3L, 4L, // src2 }, actual.nextChunk()); }
public void test_filter() { final IChunkedIterator<Long> actual = (IChunkedIterator<Long>) new ChunkedStriterator<IChunkedIterator<Long>, Long>( Arrays.asList(new Long[] { 1L, 3L, 5L }).iterator()) .addFilter(new Appender<IChunkedIterator<Long>, Long>( new ChunkedWrappedIterator<Long>(Arrays.asList( new Long[] { 2L, 3L, 4L }).iterator()))); assertEquals(new Long[] { // 1L, 3L, 5L, // src1 2L, 3L, 4L, // src2 }, actual.nextChunk()); }
/** * Unit test for chunk-at-a-time rewrite (multiplies the values in the chunk * by two). */ public void test_filter() { IChunkedIterator<Long> itr = new ChunkedStriterator(Arrays.asList( new Long[] { 1L, 2L, 3L }).iterator()) .addFilter(new ChunkedFilter<IChunkedIterator<Long>, Long, Long>() { @Override protected Long[] filterChunk(Long[] chunk) { for (int i = 0; i < chunk.length; i++) { chunk[i] *= 2; } return chunk; } }); assertEquals(new Long[] { 2L, 4L, 6L }, itr.nextChunk()); }
public void test_filter() { final IChunkedIterator<Long> actual = (IChunkedIterator<Long>) new ChunkedStriterator<IChunkedIterator<Long>, Long>( Arrays.asList(new Long[] { 1L, 3L, 5L }).iterator()) .addFilter(new MergeFilter<IChunkedIterator<Long>, Long>( new ChunkedWrappedIterator<Long>(Arrays.asList( new Long[] { 2L, 3L, 4L }).iterator()))); assertEquals(new Long[] { 1L, 2L, 3L, 4L, 5L }, actual.nextChunk()); }
public void test_filter() { final IChunkedIterator<Long> actual = (IChunkedIterator<Long>) new ChunkedStriterator<IChunkedIterator<Long>, Long>( Arrays.asList(new Long[] { 1L, 3L, 5L }).iterator()) .addFilter(new MergeFilter<IChunkedIterator<Long>, Long>( new ChunkedWrappedIterator<Long>(Arrays.asList( new Long[] { 2L, 3L, 4L }).iterator()))); assertEquals(new Long[] { 1L, 2L, 3L, 4L, 5L }, actual.nextChunk()); }
/** * Unit test for chunk-at-a-time rewrite (multiplies the values in the chunk * by two). */ public void test_filter() { IChunkedIterator<Long> itr = new ChunkedStriterator(Arrays.asList( new Long[] { 1L, 2L, 3L }).iterator()) .addFilter(new ChunkedFilter<IChunkedIterator<Long>, Long, Long>() { @Override protected Long[] filterChunk(Long[] chunk) { for (int i = 0; i < chunk.length; i++) { chunk[i] *= 2; } return chunk; } }); assertEquals(new Long[] { 2L, 4L, 6L }, itr.nextChunk()); }
/** * Unit test for correct rendering of a partial chunk when an element has * already been drawn from the iterator. */ public void test_filter2() { IChunkedIterator<Long> itr = new ChunkedStriterator(Arrays.asList( new Long[] { 1L, 2L, 3L }).iterator()) .addFilter(new ChunkedFilter<IChunkedIterator<Long>, Long, Long>() { @Override protected Long[] filterChunk(Long[] chunk) { for (int i = 0; i < chunk.length; i++) { chunk[i] *= 2; } return chunk; } }); assertEquals(Long.valueOf(2L), itr.next()); assertEquals(new Long[] { 4L, 6L }, itr.nextChunk()); }
/** * Unit test for correct rendering of a partial chunk when an element has * already been drawn from the iterator. */ public void test_filter2() { IChunkedIterator<Long> itr = new ChunkedStriterator(Arrays.asList( new Long[] { 1L, 2L, 3L }).iterator()) .addFilter(new ChunkedFilter<IChunkedIterator<Long>, Long, Long>() { @Override protected Long[] filterChunk(Long[] chunk) { for (int i = 0; i < chunk.length; i++) { chunk[i] *= 2; } return chunk; } }); assertEquals(Long.valueOf(2L), itr.next()); assertEquals(new Long[] { 4L, 6L }, itr.nextChunk()); }
/** * Verify that the iterator visits the expected chunks in the expected * order. * * @param <E> * @param chunks * @param itr */ protected <E> void assertSameChunkedIterator(final E[][] chunks, final IChunkedIterator<E> itr) { for(E[] chunk : chunks) { assertTrue(itr.hasNext()); final E[] actual = itr.nextChunk(); assertSameArray(chunk, actual); } assertFalse(itr.hasNext()); }
/** * Verify that the iterator visits the expected chunks in the expected * order. * * @param <E> * @param chunks * @param itr */ protected <E> void assertSameChunkedIterator(final E[][] chunks, final IChunkedIterator<E> itr) { for(E[] chunk : chunks) { assertTrue(itr.hasNext()); final E[] actual = itr.nextChunk(); assertSameArray(chunk, actual); } assertFalse(itr.hasNext()); }