@Test public void next_ReturnsNextElementsInOrder() { PeekIterator<Integer> tested = new PeekIterator<Integer>( listWithElements.iterator()); assertEquals(listWithElements.get(0), tested.next()); assertEquals(listWithElements.get(1), tested.next()); assertEquals(listWithElements.get(2), tested.next()); }
@Override public T next() { if (!hasNext()) { throw (new NoSuchElementException("Iterator has no elements left.")); } T toReturn = nextitem; nextitem = null; return toReturn; }
PeekIterator implements Iterator<T> { @Override public T next() { if (!hasNext()) { throw (new NoSuchElementException("Iterator has no elements left.")); } T toReturn = nextitem; nextitem = null; return toReturn; } }
PeekIterator implements Iterator<T> { @Override public T next() { if (!hasNext()) { throw (new NoSuchElementException("Iterator has no elements left.")); } T toReturn = nextitem; nextitem = null; return toReturn; } PeekIterator(Iterator<T> iterator); }
PeekIterator implements Iterator<T> { @Override public T next() { if (!hasNext()) { throw (new NoSuchElementException("Iterator has no elements left.")); } T toReturn = nextitem; nextitem = null; return toReturn; } PeekIterator(Iterator<T> iterator); @Override boolean hasNext(); @Override T next(); T peek(); @Override void remove(); }
PeekIterator implements Iterator<T> { @Override public T next() { if (!hasNext()) { throw (new NoSuchElementException("Iterator has no elements left.")); } T toReturn = nextitem; nextitem = null; return toReturn; } PeekIterator(Iterator<T> iterator); @Override boolean hasNext(); @Override T next(); T peek(); @Override void remove();  }