@Override public boolean remove(final Object value) { for (Node<E> node = header.next; node != header; node = node.next) { if (isEqualValue(node.getValue(), value)) { removeNode(node); return true; } } return false; }
@Override public E remove(final int index) { rangeCheck(index, size); checkModCount(); final E result = parent.remove(index + offset); expectedModCount = parent.modCount; size--; LinkedSubList.this.modCount++; return result; }
@Override public Iterator<E> iterator() { checkModCount(); return parent.createSubListIterator(this); }
/** * Gets the element at the specified index. * * @param index the index to retrieve * @return the element at the specified index */ @Override public E get(final int index) { checkInterval(index, 0, size() - 1); return root.get(index).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 void add(final int index, final E obj) { rangeCheck(index, size + 1); checkModCount(); parent.add(index + offset, obj); expectedModCount = parent.modCount; size++; LinkedSubList.this.modCount++; }
@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; }
@Override public void set(final E obj) { checkModCount(); getLastNodeReturned().setValue(obj); }
@Override public E get(final int index) { rangeCheck(index, size); checkModCount(); return parent.get(index + offset); }
@Override public E set(final int index, final E obj) { rangeCheck(index, size); checkModCount(); return parent.set(index + offset, obj); }
@Override public ListIterator<E> listIterator(final int index) { rangeCheck(index, size + 1); checkModCount(); return parent.createSubListListIterator(this, index); }
@Override public int indexOf(final Object value) { int i = 0; for (Node<E> node = header.next; node != header; node = node.next) { if (isEqualValue(node.getValue(), value)) { return i; } i++; } return -1; }
/** * Removes the node from the list, storing it in the cache for reuse * if the cache is not yet full. * * @param node the node to remove */ @Override protected void removeNode(final Node<E> node) { super.removeNode(node); addNodeToCache(node); }
/** * Inserts a new node into the list. * * @param nodeToInsert new node to insert * @param insertBeforeNode node to insert before * @throws NullPointerException if either node is null */ @Override protected void addNode(final Node<E> nodeToInsert, final Node<E> insertBeforeNode) { super.addNode(nodeToInsert, insertBeforeNode); broadcastNodeInserted(nodeToInsert); }
@Override public void add(final E obj) { checkModCount(); parent.addNodeBefore(next, obj); current = null; nextIndex++; expectedModCount++; }
/** * Removes the specified node from the list. * * @param node the node to remove * @throws NullPointerException if <code>node</code> is null */ @Override protected void removeNode(final Node<E> node) { super.removeNode(node); broadcastNodeRemoved(node); }
@Override public Iterator<E> iterator() { return new SetListIterator<>(super.iterator(), set); }
/** * Updates the node with a new value. * This implementation sets the value on the node. * Subclasses can override this to record the change. * * @param node node to update * @param value new value of the node */ @Override protected void updateNode(final Node<E> node, final E value) { super.updateNode(node, value); broadcastNodeChanged(node); }
/** * Creates a list iterator for the sublist. * * @param subList the sublist to get an iterator for * @param fromIndex the index to start from, relative to the sublist * @return the list iterator for the sublist */ @Override protected ListIterator<E> createSubListListIterator(final LinkedSubList<E> subList, final int fromIndex) { final SubCursor<E> cursor = new SubCursor<>(subList, fromIndex); registerCursor(cursor); return cursor; }
@Override public int lastIndexOf(final Object value) { int i = size - 1; for (Node<E> node = header.previous; node != header; node = node.previous) { if (isEqualValue(node.getValue(), value)) { return i; } i--; } return -1; }