874 |
|
* checks for concurrent modification, for use in iterators. |
875 |
|
*/ |
876 |
|
static <E> void forEachRemaining( |
877 |
< |
Consumer<? super E> action, Object[] elements, int i, int remaining) { |
877 |
> |
Consumer<? super E> action, Object[] es, int i, int remaining) { |
878 |
|
Objects.requireNonNull(action); |
879 |
< |
final int capacity = elements.length; |
879 |
> |
final int capacity = es.length; |
880 |
|
int end, to, todo; |
881 |
|
todo = (end = i + remaining) |
882 |
|
- (to = (capacity - end >= 0) ? end : capacity); |
883 |
|
for (;; to = todo, i = 0, todo = 0) { |
884 |
|
for (; i < to; i++) |
885 |
< |
action.accept(nonNullElementAt(elements, i)); |
885 |
> |
action.accept(nonNullElementAt(es, i)); |
886 |
|
if (todo == 0) break; |
887 |
|
} |
888 |
|
} |
889 |
|
|
890 |
|
static <E> void forEachRemainingDescending( |
891 |
< |
Consumer<? super E> action, Object[] elements, int i, int remaining) { |
891 |
> |
Consumer<? super E> action, Object[] es, int i, int remaining) { |
892 |
|
Objects.requireNonNull(action); |
893 |
< |
final int capacity = elements.length; |
893 |
> |
final int capacity = es.length; |
894 |
|
int end, to, todo; |
895 |
|
todo = (to = ((end = i - remaining) >= -1) ? end : -1) - end; |
896 |
|
for (;; to = (i = capacity - 1) - todo, todo = 0) { |
897 |
|
for (; i > to; i--) |
898 |
< |
action.accept(nonNullElementAt(elements, i)); |
898 |
> |
action.accept(nonNullElementAt(es, i)); |
899 |
|
if (todo == 0) break; |
900 |
|
} |
901 |
|
} |