864 |
|
} |
865 |
|
|
866 |
|
public boolean tryAdvance(Consumer<? super E> action) { |
867 |
< |
if (action == null) |
868 |
< |
throw new NullPointerException(); |
869 |
< |
final int t, i; |
870 |
< |
if ((t = getFence()) == (i = cursor)) |
871 |
< |
return false; |
867 |
> |
Objects.requireNonNull(action); |
868 |
|
final Object[] es = elements; |
869 |
+ |
if (fence < 0) { fence = tail; cursor = head; } // late-binding |
870 |
+ |
final int i; |
871 |
+ |
if ((i = cursor) == fence) |
872 |
+ |
return false; |
873 |
+ |
E e = nonNullElementAt(es, i); |
874 |
|
cursor = inc(i, es.length); |
875 |
< |
action.accept(nonNullElementAt(es, i)); |
875 |
> |
action.accept(e); |
876 |
|
return true; |
877 |
|
} |
878 |
|
|