Refine search
/** * Returns the next element in the iteration without advancing the iteration, according to the * contract of {@link PeekingIterator#peek()}. * * <p>Implementations of {@code AbstractIterator} that wish to expose this functionality should * implement {@code PeekingIterator}. */ public final T peek() { if (!hasNext()) { throw new NoSuchElementException(); } return next; } }
private boolean tryToComputeNext() { state = State.FAILED; // temporary pessimism next = computeNext(); if (state != State.DONE) { state = State.READY; return true; } return false; }
@CanIgnoreReturnValue // TODO(kak): Should we remove this? Some people are using it to prefetch? @Override public final boolean hasNext() { checkState(state != State.FAILED); switch (state) { case DONE: return false; case READY: return true; default: } return tryToComputeNext(); }
assertEquals(0, (int) iter.peek()); assertEquals(0, (int) iter.peek()); assertTrue(iter.hasNext()); assertEquals(0, (int) iter.peek()); assertEquals(0, (int) iter.next()); assertEquals(1, (int) iter.peek()); assertEquals(1, (int) iter.next()); iter.peek(); fail("peek() should throw NoSuchElementException at end"); } catch (NoSuchElementException expected) { iter.peek(); fail("peek() should continue to throw NoSuchElementException at end"); } catch (NoSuchElementException expected) { iter.next(); fail("next() should throw NoSuchElementException as usual"); } catch (NoSuchElementException expected) { iter.peek(); fail("peek() should still throw NoSuchElementException after next()"); } catch (NoSuchElementException expected) {
@Override public boolean hasNext() { return filtered.hasNext(); } @Override
@Override protected Iterator<A> computeNext() { return new AbstractIterator<A>() { int c = 0; @Override protected A computeNext() { if (c == count || !a.hasNext()) { endOfData(); return null; } return a.next(); } }; } };
@Override public T next() { T element = super.next(); canRemove = true; elementToRemove = element; return element; }
assertEquals(0, (int) iter.peek()); assertEquals(0, (int) iter.peek()); assertTrue(iter.hasNext()); assertEquals(0, (int) iter.peek()); assertEquals(0, (int) iter.next()); assertEquals(1, (int) iter.peek()); assertEquals(1, (int) iter.next()); iter.peek(); fail("peek() should throw NoSuchElementException at end"); } catch (NoSuchElementException expected) { iter.peek(); fail("peek() should continue to throw NoSuchElementException at end"); } catch (NoSuchElementException expected) { iter.next(); fail("next() should throw NoSuchElementException as usual"); } catch (NoSuchElementException expected) { iter.peek(); fail("peek() should still throw NoSuchElementException after next()"); } catch (NoSuchElementException expected) {
@Override protected Iterator<T> computeNext() { if (currentRow != null) { while (currentRow.hasNext()) { currentRow.next(); } } if (!iterator.hasNext()) { return endOfData(); } currentRow = new AbstractIterator<T>() { int count = partitionSize; @Override protected T computeNext() { if (count == 0) { return endOfData(); } count--; if (iterator.hasNext()) { return iterator.next(); } else { if (!padToSize) { endOfData(); } return null; } } }; return currentRow; } };
@Override public Entry<Player, TValue> next() { return filtered.next(); } @Override
@CanIgnoreReturnValue // TODO(kak): Should we remove this? @Override public final T next() { if (!hasNext()) { throw new NoSuchElementException(); } state = State.NOT_READY; T result = next; next = null; return result; }
private boolean tryToComputeNext() { state = State.FAILED; // temporary pessimism next = computeNext(); if (state != State.DONE) { state = State.READY; return true; } return false; }
@CanIgnoreReturnValue // TODO(kak): Should we remove this? Some people are using it to prefetch? @Override public final boolean hasNext() { checkState(state != State.FAILED); switch (state) { case DONE: return false; case READY: return true; default: } return tryToComputeNext(); }
return new AbstractIterator<Row<ByteBuffer, Composite>>() { @Override protected Row<ByteBuffer, Composite> computeNext() {
/** * Returns the next element in the iteration without advancing the iteration, according to the * contract of {@link PeekingIterator#peek()}. * * <p>Implementations of {@code AbstractIterator} that wish to expose this functionality should * implement {@code PeekingIterator}. */ public final T peek() { if (!hasNext()) { throw new NoSuchElementException(); } return next; } }
private boolean tryToComputeNext() { state = State.FAILED; // temporary pessimism next = computeNext(); if (state != State.DONE) { state = State.READY; return true; } return false; }
@CanIgnoreReturnValue // TODO(kak): Should we remove this? Some people are using it to prefetch? @Override public final boolean hasNext() { checkState(state != State.FAILED); switch (state) { case DONE: return false; case READY: return true; default: } return tryToComputeNext(); }
Iterator<Row> secondaryIterator = new AbstractIterator<Row>() { private Iterator<SoftReference<List<Row>>> _softGroupsIterator = softCache.iterator(); private Iterator<Row> _currentGroupIterator = null;
/** * Returns the next element in the iteration without advancing the iteration, according to the * contract of {@link PeekingIterator#peek()}. * * <p>Implementations of {@code AbstractIterator} that wish to expose this functionality should * implement {@code PeekingIterator}. */ public final T peek() { if (!hasNext()) { throw new NoSuchElementException(); } return next; } }
private boolean tryToComputeNext() { state = State.FAILED; // temporary pessimism next = computeNext(); if (state != State.DONE) { state = State.READY; return true; } return false; }