@Override public Iterator<E> iterator() { final Iterator<E> valueIterator = value.iterator(); return new ForwardingIterator<E>() { @Override protected Iterator<E> delegate() { return valueIterator; } @Override public void remove() { super.remove(); change(); } }; }
@Override public Iterator<E> iterator() { final Iterator<E> delegateIterator = delegate().iterator(); return new ForwardingIterator<E>() { @Override protected Iterator<E> delegate() { return delegateIterator; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
@Override public Iterator<E> iterator() { final class ReadOnlyIterator extends AbstractIterator<E> { Node<E> current = top.get(); @Override protected E computeNext() { for (;;) { if (current == null) { return endOfData(); } E e = current.get(); current = current.next; if (e != null) { return e; } } } }; return new ForwardingIterator<E>() { final ReadOnlyIterator delegate = new ReadOnlyIterator(); @Override public void remove() { checkState(delegate.current != null); delegate.current.lazySet(null); } @Override protected Iterator<E> delegate() { return delegate; } }; }