Esempio n. 1
0
 public void add(int index, E element) {
   if (index < 0 || index > size) throw new IndexOutOfBoundsException();
   checkForComodification();
   l.add(index + offset, element);
   expectedModCount = l.modCount;
   size++;
   modCount++;
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  *
  * <p>This implementation gets an iterator over the specified collection and iterates over it,
  * inserting the elements obtained from the iterator into this list at the appropriate position,
  * one at a time, using {@code add(int, E)}. Many implementations will override this method for
  * efficiency.
  *
  * <p>Note that this implementation throws an {@code UnsupportedOperationException} unless {@link
  * #add(int, Object) add(int, E)} is overridden.
  *
  * @throws UnsupportedOperationException {@inheritDoc}
  * @throws ClassCastException {@inheritDoc}
  * @throws NullPointerException {@inheritDoc}
  * @throws IllegalArgumentException {@inheritDoc}
  * @throws IndexOutOfBoundsException {@inheritDoc}
  */
 public boolean addAll(int index, Collection<? extends E> c) {
   boolean modified = false;
   Iterator<? extends E> e = c.iterator();
   while (e.hasNext()) {
     add(index++, e.next());
     modified = true;
   }
   return modified;
 }
Esempio n. 3
0
 /**
  * Appends the specified element to the end of this list (optional operation).
  *
  * <p>Lists that support this operation may place limitations on what elements may be added to
  * this list. In particular, some lists will refuse to add null elements, and others will impose
  * restrictions on the type of elements that may be added. List classes should clearly specify in
  * their documentation any restrictions on what elements may be added.
  *
  * <p>This implementation calls {@code add(size(), e)}.
  *
  * <p>Note that this implementation throws an {@code UnsupportedOperationException} unless {@link
  * #add(int, Object) add(int, E)} is overridden.
  *
  * @param e element to be appended to this list
  * @return {@code true} (as specified by {@link Collection#add})
  * @throws UnsupportedOperationException if the {@code add} operation is not supported by this
  *     list
  * @throws ClassCastException if the class of the specified element prevents it from being added
  *     to this list
  * @throws NullPointerException if the specified element is null and this list does not permit
  *     null elements
  * @throws IllegalArgumentException if some property of this element prevents it from being added
  *     to this list
  */
 public boolean add(E e) {
   add(size(), e);
   return true;
 }