1452 |
|
|
1453 |
|
@SuppressWarnings("unchecked") |
1454 |
|
public void forEachRemaining(Consumer<? super E> action) { |
1455 |
– |
int i, hi; // hoist accesses and checks from loop |
1456 |
– |
Object[] a; |
1455 |
|
if (action == null) |
1456 |
|
throw new NullPointerException(); |
1457 |
< |
if ((hi = fence) < 0) { |
1458 |
< |
synchronized (Vector.this) { |
1459 |
< |
expectedModCount = modCount; |
1460 |
< |
a = array = elementData; |
1461 |
< |
hi = fence = elementCount; |
1462 |
< |
} |
1463 |
< |
} |
1466 |
< |
else |
1467 |
< |
a = array; |
1468 |
< |
if (a != null && (i = index) >= 0 && (index = hi) <= a.length) { |
1469 |
< |
while (i < hi) |
1470 |
< |
action.accept((E) a[i++]); |
1471 |
< |
if (modCount == expectedModCount) |
1472 |
< |
return; |
1473 |
< |
} |
1474 |
< |
throw new ConcurrentModificationException(); |
1457 |
> |
final int hi = getFence(); |
1458 |
> |
final Object[] a = array; |
1459 |
> |
int i; |
1460 |
> |
for (i = index, index = hi; i < hi; i++) |
1461 |
> |
action.accept((E) a[i]); |
1462 |
> |
if (modCount != expectedModCount) |
1463 |
> |
throw new ConcurrentModificationException(); |
1464 |
|
} |
1465 |
|
|
1466 |
|
public long estimateSize() { |