Java 类com.google.common.collect.ForwardingIterator 实例源码

项目:boxes    文件:CollectionBox.java   
@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();
        }
    };
}
项目:boxes    文件:BoxFamily.java   
@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();
        }
    };
}
项目:multiway-pool    文件:EliminationStack.java   
@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;
    }
  };
}