@Override public boolean add(final E value) { addLast(value); return true; }
/** * Creates a new node with the specified object as its * <code>value</code> and inserts it before <code>node</code>. * <p> * This implementation uses {@link #createNode(Object)} and * {@link #addNode(AbstractLinkedList.Node,AbstractLinkedList.Node)}. * * @param node node to insert before * @param value value of the newly added node * @throws NullPointerException if <code>node</code> is null */ protected void addNodeBefore(final Node<E> node, final E value) { final Node<E> newNode = createNode(value); addNode(newNode, node); }
@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; }
/** * Deserializes the data held in this object to the stream specified. * <p> * The first serializable subclass must call this method from * <code>readObject</code>. * * @param inputStream the stream to read the object from * @throws IOException if any error occurs while reading from the stream * @throws ClassNotFoundException if a class read from the stream can not be loaded */ @SuppressWarnings("unchecked") protected void doReadObject(final ObjectInputStream inputStream) throws IOException, ClassNotFoundException { init(); final int size = inputStream.readInt(); for (int i = 0; i < size; i++) { add((E) inputStream.readObject()); } }
public boolean addLast(final E o) { addNodeBefore(header, o); return true; }
@Override public boolean addAll(final Collection<? extends E> coll) { return addAll(size, coll); }
/** * The equivalent of a default constructor, broken out so it can be called * by any constructor and by <code>readObject</code>. * Subclasses which override this method should make sure they call super, * so the list is initialised properly. */ protected void init() { header = createHeaderNode(); }
@Override public boolean containsAll(final Collection<?> coll) { for (final Object o : coll) { if (!contains(o)) { return false; } } return true; }
public boolean addFirst(final E o) { addNodeAfter(header, o); return true; }
@Override public Iterator<E> iterator() { checkModCount(); return parent.createSubListIterator(this); }
/** * 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 int index, final E obj) { rangeCheck(index, size + 1); checkModCount(); parent.add(index + offset, obj); expectedModCount = parent.modCount; size++; LinkedSubList.this.modCount++; }
/** * Creates a new node, either by reusing one from the cache or creating * a new one. * * @param value value of the new node * @return the newly created node */ @Override protected Node<E> createNode(final E value) { final Node<E> cachedNode = getNodeFromCache(); if (cachedNode == null) { return super.createNode(value); } cachedNode.setValue(value); return cachedNode; }
@Override public void add(final int index, final E value) { final Node<E> node = getNode(index, true); addNodeBefore(node, value); }
@Override public void add(final E obj) { checkModCount(); parent.addNodeBefore(next, obj); current = null; nextIndex++; expectedModCount++; }
@Override public boolean addAll(final int index, final Collection<? extends E> coll) { rangeCheck(index, size + 1); final int cSize = coll.size(); if (cSize == 0) { return false; } checkModCount(); parent.addAll(offset + index, coll); expectedModCount = parent.modCount; size += cSize; LinkedSubList.this.modCount++; return true; }
/** * Creates a new node with the specified object as its * <code>value</code> and inserts it after <code>node</code>. * <p> * This implementation uses {@link #createNode(Object)} and * {@link #addNode(AbstractLinkedList.Node,AbstractLinkedList.Node)}. * * @param node node to insert after * @param value value of the newly added node * @throws NullPointerException if <code>node</code> is null */ protected void addNodeAfter(final Node<E> node, final E value) { final Node<E> newNode = createNode(value); addNode(newNode, node.next); }