public void setIterator(int index, Iterator<? extends E> iterator) throws IndexOutOfBoundsException {
        checkLocked();
        if (iterator == null) {
            throw new NullPointerException("Iterator must not be null");
        }
        iteratorChain.set(index, iterator);
    }
Set the Iterator at the given index

@param index    index of the Iterator to replace
@param iterator Iterator to place at the given index
@throws IndexOutOfBoundsException if index &lt; 0 or index &gt; size()
@throws IllegalStateException     if I've already started iterating
@throws NullPointerException      if the iterator is null
jphp-runtime/src/php/runtime/common/collections/iterators/IteratorChain.java