912 |
|
} |
913 |
|
|
914 |
|
@Override |
915 |
< |
@SuppressWarnings("unchecked") |
916 |
< |
public void forEachRemaining(Consumer<? super E> consumer) { |
917 |
< |
Objects.requireNonNull(consumer); |
915 |
> |
public void forEachRemaining(Consumer<? super E> action) { |
916 |
> |
Objects.requireNonNull(action); |
917 |
|
final int size = ArrayList.this.size; |
918 |
|
int i = cursor; |
919 |
< |
if (i >= size) { |
920 |
< |
return; |
921 |
< |
} |
922 |
< |
final Object[] elementData = ArrayList.this.elementData; |
923 |
< |
if (i >= elementData.length) { |
924 |
< |
throw new ConcurrentModificationException(); |
919 |
> |
if (i < size) { |
920 |
> |
final Object[] es = elementData; |
921 |
> |
if (i >= es.length) |
922 |
> |
throw new ConcurrentModificationException(); |
923 |
> |
for (; i < size && modCount == expectedModCount; i++) |
924 |
> |
action.accept(elementAt(es, i)); |
925 |
> |
// update once at end to reduce heap write traffic |
926 |
> |
cursor = i; |
927 |
> |
lastRet = i - 1; |
928 |
> |
checkForComodification(); |
929 |
|
} |
927 |
– |
while (i != size && modCount == expectedModCount) { |
928 |
– |
consumer.accept((E) elementData[i++]); |
929 |
– |
} |
930 |
– |
// update once at end of iteration to reduce heap write traffic |
931 |
– |
cursor = i; |
932 |
– |
lastRet = i - 1; |
933 |
– |
checkForComodification(); |
930 |
|
} |
931 |
|
|
932 |
|
final void checkForComodification() { |
1187 |
|
return (E) elementData[offset + (lastRet = i)]; |
1188 |
|
} |
1189 |
|
|
1190 |
< |
@SuppressWarnings("unchecked") |
1191 |
< |
public void forEachRemaining(Consumer<? super E> consumer) { |
1196 |
< |
Objects.requireNonNull(consumer); |
1190 |
> |
public void forEachRemaining(Consumer<? super E> action) { |
1191 |
> |
Objects.requireNonNull(action); |
1192 |
|
final int size = SubList.this.size; |
1193 |
|
int i = cursor; |
1194 |
< |
if (i >= size) { |
1195 |
< |
return; |
1196 |
< |
} |
1197 |
< |
final Object[] elementData = root.elementData; |
1198 |
< |
if (offset + i >= elementData.length) { |
1199 |
< |
throw new ConcurrentModificationException(); |
1194 |
> |
if (i < size) { |
1195 |
> |
final Object[] es = root.elementData; |
1196 |
> |
if (offset + i >= es.length) |
1197 |
> |
throw new ConcurrentModificationException(); |
1198 |
> |
for (; i < size && modCount == expectedModCount; i++) |
1199 |
> |
action.accept(elementAt(es, offset + i)); |
1200 |
> |
// update once at end to reduce heap write traffic |
1201 |
> |
cursor = i; |
1202 |
> |
lastRet = i - 1; |
1203 |
> |
checkForComodification(); |
1204 |
|
} |
1206 |
– |
while (i != size && modCount == expectedModCount) { |
1207 |
– |
consumer.accept((E) elementData[offset + (i++)]); |
1208 |
– |
} |
1209 |
– |
// update once at end of iteration to reduce heap write traffic |
1210 |
– |
cursor = i; |
1211 |
– |
lastRet = i - 1; |
1212 |
– |
checkForComodification(); |
1205 |
|
} |
1206 |
|
|
1207 |
|
public int nextIndex() { |