Esempio n. 1
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. 2
0
  public boolean addAll(int index, Collection<? extends E> c) {
    if (index < 0 || index > size)
      throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
    int cSize = c.size();
    if (cSize == 0) return false;

    checkForComodification();
    l.addAll(offset + index, c);
    expectedModCount = l.modCount;
    size += cSize;
    modCount++;
    return true;
  }