@Test public void repeatable() { ForwardIterator<Integer> iter = new ForwardIterator<>(Stream.of(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10).iterator()); ForwardIterator<Integer> copy = iter.clone(); List<Integer> iter_seen = new ArrayList<>(); List<Integer> copy_seen = new ArrayList<>(); iter.forEachRemaining(iter_seen::add); copy.forEachRemaining(copy_seen::add); assertEquals(iter_seen, copy_seen); }
@Override public ForwardIterator<T> clone() { return new ForwardIterator<>(next_); }
ForwardIterator implements Iterator<T>, Cloneable { @Override public ForwardIterator<T> clone() { return new ForwardIterator<>(next_); } }
ForwardIterator implements Iterator<T>, Cloneable { @Override public ForwardIterator<T> clone() { return new ForwardIterator<>(next_); } ForwardIterator(Iterator<T> iter); private  ForwardIterator(Chain<T> next); }
ForwardIterator implements Iterator<T>, Cloneable { @Override public ForwardIterator<T> clone() { return new ForwardIterator<>(next_); } ForwardIterator(Iterator<T> iter); private  ForwardIterator(Chain<T> next); @Override boolean hasNext(); @Override T next(); @Override ForwardIterator<T> clone(); }
ForwardIterator implements Iterator<T>, Cloneable { @Override public ForwardIterator<T> clone() { return new ForwardIterator<>(next_); } ForwardIterator(Iterator<T> iter); private  ForwardIterator(Chain<T> next); @Override boolean hasNext(); @Override T next(); @Override ForwardIterator<T> clone();  }