1188 |
|
throw new IndexOutOfBoundsException(outOfBounds(index, size)); |
1189 |
|
} |
1190 |
|
|
1191 |
+ |
private void rangeCheckForAdd(int index) { |
1192 |
+ |
// assert Thread.holdsLock(lock); |
1193 |
+ |
if (index < 0 || index > size) |
1194 |
+ |
throw new IndexOutOfBoundsException(outOfBounds(index, size)); |
1195 |
+ |
} |
1196 |
+ |
|
1197 |
|
public Object[] toArray() { |
1198 |
|
final Object[] es; |
1199 |
|
final int offset; |
1353 |
|
public void add(int index, E element) { |
1354 |
|
synchronized (lock) { |
1355 |
|
checkForComodification(); |
1356 |
< |
if (index < 0 || index > size) |
1351 |
< |
throw new IndexOutOfBoundsException( |
1352 |
< |
outOfBounds(index, size)); |
1356 |
> |
rangeCheckForAdd(index); |
1357 |
|
CopyOnWriteArrayList.this.add(offset + index, element); |
1358 |
|
expectedArray = getArray(); |
1359 |
|
size++; |
1372 |
|
|
1373 |
|
public boolean addAll(int index, Collection<? extends E> c) { |
1374 |
|
synchronized (lock) { |
1375 |
< |
if (index < 0 || index > size) |
1372 |
< |
throw new IndexOutOfBoundsException( |
1373 |
< |
outOfBounds(index, size)); |
1375 |
> |
rangeCheckForAdd(index); |
1376 |
|
final Object[] oldArray = getArrayChecked(); |
1377 |
|
boolean modified = |
1378 |
|
CopyOnWriteArrayList.this.addAll(offset + index, c); |
1423 |
|
public ListIterator<E> listIterator(int index) { |
1424 |
|
synchronized (lock) { |
1425 |
|
checkForComodification(); |
1426 |
< |
if (index < 0 || index > size) |
1425 |
< |
throw new IndexOutOfBoundsException |
1426 |
< |
(outOfBounds(index, size)); |
1426 |
> |
rangeCheckForAdd(index); |
1427 |
|
return new COWSubListIterator<E>( |
1428 |
|
CopyOnWriteArrayList.this, index, offset, size); |
1429 |
|
} |