710 |
|
throw new NoSuchElementException(); |
711 |
|
final Object[] es = elements; |
712 |
|
E e = nonNullElementAt(es, cursor); |
713 |
< |
lastRet = cursor; |
714 |
< |
cursor = inc(cursor, es.length); |
713 |
> |
cursor = inc(lastRet = cursor, es.length); |
714 |
|
remaining--; |
715 |
|
return e; |
716 |
|
} |
758 |
|
throw new NoSuchElementException(); |
759 |
|
final Object[] es = elements; |
760 |
|
E e = nonNullElementAt(es, cursor); |
761 |
< |
lastRet = cursor; |
763 |
< |
cursor = dec(cursor, es.length); |
761 |
> |
cursor = dec(lastRet = cursor, es.length); |
762 |
|
remaining--; |
763 |
|
return e; |
764 |
|
} |
862 |
|
} |
863 |
|
|
864 |
|
public boolean tryAdvance(Consumer<? super E> action) { |
865 |
< |
if (action == null) |
868 |
< |
throw new NullPointerException(); |
869 |
< |
final int t, i; |
870 |
< |
if ((t = getFence()) == (i = cursor)) |
871 |
< |
return false; |
865 |
> |
Objects.requireNonNull(action); |
866 |
|
final Object[] es = elements; |
867 |
+ |
if (fence < 0) { fence = tail; cursor = head; } // late-binding |
868 |
+ |
final int i; |
869 |
+ |
if ((i = cursor) == fence) |
870 |
+ |
return false; |
871 |
+ |
E e = nonNullElementAt(es, i); |
872 |
|
cursor = inc(i, es.length); |
873 |
< |
action.accept(nonNullElementAt(es, i)); |
873 |
> |
action.accept(e); |
874 |
|
return true; |
875 |
|
} |
876 |
|
|