/** * Appends the specified element to the end of this list. * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean add(E o) { insertListable(_head.prev(),null,o); return true; }
/** * Inserts the specified element at the beginning of this list. * (Equivalent to {@link #add(int,java.lang.Object) <tt>add(0,o)</tt>}). * * @param o element to be prepended to this list. * @return <tt>true</tt> */ public boolean addFirst(E o) { insertListable(null,_head.next(),o); return true; }
/** * Inserts the specified element at the end of this list. * (Equivalent to {@link #add(java.lang.Object)}). * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean addLast(E o) { insertListable(_head.prev(),null,o); return true; }
/** * Appends all of the elements in the specified collection to the end of * this list, in the order that they are returned by the specified * {@link Collection}'s {@link Iterator}. The behavior of this operation is * unspecified if the specified collection is modified while * the operation is in progress. (Note that this will occur if the * specified collection is this list, and it's nonempty.) * * @param c collection whose elements are to be added to this list. * @return <tt>true</tt> if this list changed as a result of the call. * * @throws ClassCastException if the class of an element in the specified * collection prevents it from being added to this list. * @throws IllegalArgumentException if some aspect of an element in the * specified collection prevents it from being added to this * list. */ public boolean addAll(Collection<? extends E> c) { if(c.isEmpty()) { return false; } Iterator<? extends E> it = c.iterator(); while(it.hasNext()) { insertListable(_head.prev(),null,it.next()); } return true; }
Iterator<? extends E> it = c.iterator(); while(it.hasNext()) { pred = insertListable(pred,succ,it.next());
/** * Inserts the specified element at the specified position in this list. * Shifts the element currently at that position (if any) and any subsequent * elements to the right (adds one to their indices). * * @param index index at which the specified element is to be inserted. * @param element element to be inserted. * * @throws ClassCastException if the class of the specified element * prevents it from being added to this list. * @throws IllegalArgumentException if some aspect of the specified * element prevents it from being added to this list. * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index > size()). */ public void add(int index, E element) { if(index == _size) { add(element); } else { if(index < 0 || index > _size) { throw new IndexOutOfBoundsException(String.valueOf(index) + " < 0 or " + String.valueOf(index) + " > " + _size); } Listable<E> succ = (isEmpty() ? null : getListableAt(index)); Listable<E> pred = (null == succ ? null : succ.prev()); insertListable(pred,succ,element); } }
/** * Inserts a new <i>value</i> into my * list, after the specified <i>before</i> element, and before the * specified <i>after</i> element * * @return the newly created {@link CursorableLinkedList.Listable} */ @Override protected Listable<E> insertListable(Listable<E> before, Listable<E> after, E value) { _modCount++; _size++; Listable<E> elt = _list.insertListable((null == before ? _pre : before), (null == after ? _post : after),value); if(null == _head.next()) { _head.setNext(elt); _head.setPrev(elt); } if(before == _head.prev()) { _head.setPrev(elt); } if(after == _head.next()) { _head.setNext(elt); } broadcastListableInserted(elt); return elt; }
/** * Inserts the specified element at the end of this list. * (Equivalent to {@link #add(java.lang.Object)}). * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean addLast(E o) { insertListable(_head.prev(),null,o); return true; }
/** * Inserts the specified element at the beginning of this list. * (Equivalent to {@link #add(int,java.lang.Object) <tt>add(0,o)</tt>}). * * @param o element to be prepended to this list. * @return <tt>true</tt> */ public boolean addFirst(Object o) { insertListable(null,_head.next(),o); return true; }
/** * Appends the specified element to the end of this list. * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean add(Object o) { insertListable(_head.prev(),null,o); return true; }
/** * Appends the specified element to the end of this list. * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean add(E o) { insertListable(_head.prev(),null,o); return true; }
/** * Inserts the specified element at the beginning of this list. * (Equivalent to {@link #add(int,java.lang.Object) <tt>add(0,o)</tt>}). * * @param o element to be prepended to this list. * @return <tt>true</tt> */ public boolean addFirst(Object o) { insertListable(null,_head.next(),o); return true; }
/** * Inserts the specified element at the end of this list. * (Equivalent to {@link #add(java.lang.Object)}). * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean addLast(E o) { insertListable(_head.prev(),null,o); return true; }
/** * Appends the specified element to the end of this list. * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean add(Object o) { insertListable(_head.prev(),null,o); return true; }
/** * Inserts the specified element at the end of this list. * (Equivalent to {@link #add(java.lang.Object)}). * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean addLast(Object o) { insertListable(_head.prev(),null,o); return true; }
/** * Appends the specified element to the end of this list. * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean add(E o) { insertListable(_head.prev(),null,o); return true; }
public void add(Object o) { checkForComod(); _cur.setPrev(insertListable(_cur.prev(),_cur.next(),o)); _lastReturned = null; _nextIndex++; _expectedModCount++; }
public void add(Object o) { checkForComod(); _cur.setPrev(insertListable(_cur.prev(),_cur.next(),o)); _lastReturned = null; _nextIndex++; _expectedModCount++; }
public void add(Object o) { checkForComod(); Listable elt = insertListable(_cur.prev(),_cur.next(),o); _cur.setPrev(elt); _cur.setNext(elt.next()); _lastReturned = null; _nextIndex++; _expectedModCount++; }
public void add(Object o) { checkForComod(); Listable elt = insertListable(_cur.prev(),_cur.next(),o); _cur.setPrev(elt); _cur.setNext(elt.next()); _lastReturned = null; _nextIndex++; _expectedModCount++; }