/** * Create a ListIterator for a list. * * @param parent the parent list * @param fromIndex the index to start at * @throws IndexOutOfBoundsException if fromIndex is less than 0 or greater than the size of the list */ protected LinkedListIterator(final AbstractLinkedList<E> parent, final int fromIndex) throws IndexOutOfBoundsException { super(); this.parent = parent; this.expectedModCount = parent.modCount; this.next = parent.getNode(fromIndex, true); this.nextIndex = fromIndex; }
@Override public boolean addAll(final int index, final Collection<? extends E> coll) { final Node<E> node = getNode(index, true); for (final E e : coll) { addNodeBefore(node, e); } return true; }
@Override public void add(final int index, final E value) { final Node<E> node = getNode(index, true); addNodeBefore(node, value); }
@Override public E get(final int index) { final Node<E> node = getNode(index, false); return node.getValue(); }
@Override public E remove(final int index) { final Node<E> node = getNode(index, false); final E oldValue = node.getValue(); removeNode(node); return oldValue; }
@Override public E set(final int index, final E value) { final Node<E> node = getNode(index, false); final E oldValue = node.getValue(); updateNode(node, value); return oldValue; }