370 |
|
return (E) a[index]; |
371 |
|
} |
372 |
|
|
373 |
+ |
static String outOfBounds(int index, int size) { |
374 |
+ |
return "Index: " + index + ", Size: " + size; |
375 |
+ |
} |
376 |
+ |
|
377 |
|
/** |
378 |
|
* {@inheritDoc} |
379 |
|
* |
436 |
|
Object[] elements = getArray(); |
437 |
|
int len = elements.length; |
438 |
|
if (index > len || index < 0) |
439 |
< |
throw new IndexOutOfBoundsException("Index: "+index+ |
436 |
< |
", Size: "+len); |
439 |
> |
throw new IndexOutOfBoundsException(outOfBounds(index, len)); |
440 |
|
Object[] newElements; |
441 |
|
int numMoved = len - index; |
442 |
|
if (numMoved == 0) |
793 |
|
Object[] elements = getArray(); |
794 |
|
int len = elements.length; |
795 |
|
if (index > len || index < 0) |
796 |
< |
throw new IndexOutOfBoundsException("Index: "+index+ |
794 |
< |
", Size: "+len); |
796 |
> |
throw new IndexOutOfBoundsException(outOfBounds(index, len)); |
797 |
|
if (cs.length == 0) |
798 |
|
return false; |
799 |
|
int numMoved = len - index; |
1022 |
|
Object[] elements = getArray(); |
1023 |
|
int len = elements.length; |
1024 |
|
if (index < 0 || index > len) |
1025 |
< |
throw new IndexOutOfBoundsException("Index: "+index); |
1025 |
> |
throw new IndexOutOfBoundsException(outOfBounds(index, len)); |
1026 |
|
|
1027 |
|
return new COWIterator<E>(elements, index); |
1028 |
|
} |
1186 |
|
private void rangeCheck(int index) { |
1187 |
|
// assert Thread.holdsLock(l.lock); |
1188 |
|
if (index < 0 || index >= size) |
1189 |
< |
throw new IndexOutOfBoundsException("Index: "+index+ |
1188 |
< |
",Size: "+size); |
1189 |
> |
throw new IndexOutOfBoundsException(outOfBounds(index, size)); |
1190 |
|
} |
1191 |
|
|
1192 |
|
public E set(int index, E element) { |
1218 |
|
synchronized (l.lock) { |
1219 |
|
checkForComodification(); |
1220 |
|
if (index < 0 || index > size) |
1221 |
< |
throw new IndexOutOfBoundsException(); |
1221 |
> |
throw new IndexOutOfBoundsException |
1222 |
> |
(outOfBounds(index, size)); |
1223 |
|
l.add(index+offset, element); |
1224 |
|
expectedArray = l.getArray(); |
1225 |
|
size++; |
1265 |
|
synchronized (l.lock) { |
1266 |
|
checkForComodification(); |
1267 |
|
if (index < 0 || index > size) |
1268 |
< |
throw new IndexOutOfBoundsException("Index: "+index+ |
1269 |
< |
", Size: "+size); |
1268 |
> |
throw new IndexOutOfBoundsException |
1269 |
> |
(outOfBounds(index, size)); |
1270 |
|
return new COWSubListIterator<E>(l, index, offset, size); |
1271 |
|
} |
1272 |
|
} |