| 172 | /// |
| 173 | /// - `ArrayIndexOutOfBoundsException`: if `location size()`. |
| 174 | @Override |
| 175 | public synchronized boolean addAll(int location, |
| 176 | Collection<? extends E> collection) { |
| 177 | if (0 <= location && location <= elementCount) { |
| 178 | int size = collection.size(); |
| 179 | if (size == 0) { |
| 180 | return false; |
| 181 | } |
| 182 | int required = size - (elementData.length - elementCount); |
| 183 | if (required > 0) { |
| 184 | growBy(required); |
| 185 | } |
| 186 | int count = elementCount - location; |
| 187 | if (count > 0) { |
| 188 | System.arraycopy(elementData, location, elementData, location |
| 189 | + size, count); |
| 190 | } |
| 191 | Iterator<? extends E> it = collection.iterator(); |
| 192 | while (it.hasNext()) { |
| 193 | elementData[location++] = it.next(); |
| 194 | } |
| 195 | elementCount += size; |
| 196 | modCount++; |
| 197 | return true; |
| 198 | } |
| 199 | throw new ArrayIndexOutOfBoundsException(location); |
| 200 | } |
| 201 | |
| 202 | /// Adds the objects in the specified collection to the end of this vector. |
| 203 | /// |