187 |
|
Object[] elements = c.toArray(); |
188 |
|
// defend against c.toArray (incorrectly) not returning Object[] |
189 |
|
// (see e.g. https://bugs.openjdk.java.net/browse/JDK-6260652) |
190 |
+ |
size = elements.length; |
191 |
|
if (elements.getClass() != Object[].class) |
192 |
|
elements = Arrays.copyOf(elements, size, Object[].class); |
193 |
|
for (Object obj : elements) |
194 |
|
Objects.requireNonNull(obj); |
194 |
– |
size = elements.length; |
195 |
|
this.elements = elements; |
196 |
|
} |
197 |
|
|
365 |
|
*/ |
366 |
|
public E removeFirst() { |
367 |
|
// checkInvariants(); |
368 |
< |
E x = pollFirst(); |
369 |
< |
if (x == null) |
368 |
> |
E e = pollFirst(); |
369 |
> |
if (e == null) |
370 |
|
throw new NoSuchElementException(); |
371 |
< |
return x; |
371 |
> |
return e; |
372 |
|
} |
373 |
|
|
374 |
|
/** |
376 |
|
*/ |
377 |
|
public E removeLast() { |
378 |
|
// checkInvariants(); |
379 |
< |
E x = pollLast(); |
380 |
< |
if (x == null) |
379 |
> |
E e = pollLast(); |
380 |
> |
if (e == null) |
381 |
|
throw new NoSuchElementException(); |
382 |
< |
return x; |
382 |
> |
return e; |
383 |
|
} |
384 |
|
|
385 |
|
public E pollFirst() { |