261 |
|
|
262 |
|
public E pollFirst() { |
263 |
|
int h = head; |
264 |
< |
@SuppressWarnings("unchecked") E result = (E) elements[h]; |
264 |
> |
@SuppressWarnings("unchecked") |
265 |
> |
E result = (E) elements[h]; |
266 |
|
// Element is null if deque empty |
267 |
|
if (result == null) |
268 |
|
return null; |
273 |
|
|
274 |
|
public E pollLast() { |
275 |
|
int t = (tail - 1) & (elements.length - 1); |
276 |
< |
@SuppressWarnings("unchecked") E result = (E) elements[t]; |
276 |
> |
@SuppressWarnings("unchecked") |
277 |
> |
E result = (E) elements[t]; |
278 |
|
if (result == null) |
279 |
|
return null; |
280 |
|
elements[t] = null; |
286 |
|
* @throws NoSuchElementException {@inheritDoc} |
287 |
|
*/ |
288 |
|
public E getFirst() { |
289 |
< |
@SuppressWarnings("unchecked") E result = (E) elements[head]; |
289 |
> |
@SuppressWarnings("unchecked") |
290 |
> |
E result = (E) elements[head]; |
291 |
|
if (result == null) |
292 |
|
throw new NoSuchElementException(); |
293 |
|
return result; |
603 |
|
public E next() { |
604 |
|
if (cursor == fence) |
605 |
|
throw new NoSuchElementException(); |
606 |
< |
@SuppressWarnings("unchecked") E result = (E) elements[cursor]; |
606 |
> |
@SuppressWarnings("unchecked") |
607 |
> |
E result = (E) elements[cursor]; |
608 |
|
// This check doesn't catch all possible comodifications, |
609 |
|
// but does catch the ones that corrupt traversal |
610 |
|
if (tail != fence || result == null) |
643 |
|
if (cursor == fence) |
644 |
|
throw new NoSuchElementException(); |
645 |
|
cursor = (cursor - 1) & (elements.length - 1); |
646 |
< |
@SuppressWarnings("unchecked") E result = (E) elements[cursor]; |
646 |
> |
@SuppressWarnings("unchecked") |
647 |
> |
E result = (E) elements[cursor]; |
648 |
|
if (head != fence || result == null) |
649 |
|
throw new ConcurrentModificationException(); |
650 |
|
lastRet = cursor; |