257 |
|
*/ |
258 |
|
public boolean addAll(int index, Collection c) { |
259 |
|
int numNew = c.size(); |
260 |
< |
if (numNew==0) |
261 |
< |
return false; |
260 |
> |
if (numNew==0) { |
261 |
> |
if (index < 0 || index >= size) |
262 |
> |
throw new IndexOutOfBoundsException(); |
263 |
> |
else |
264 |
> |
return false; |
265 |
> |
} |
266 |
|
modCount++; |
267 |
|
|
268 |
|
Entry successor = (index==size ? header : entry(index)); |
710 |
|
public Object peek() { |
711 |
|
if (size==0) |
712 |
|
return null; |
713 |
< |
return header.previous.element; |
713 |
> |
return getFirst(); |
714 |
|
} |
715 |
|
|
716 |
|
public Object element() { |
717 |
< |
if (size==0) |
714 |
< |
throw new NoSuchElementException(); |
715 |
< |
return header.previous.element; |
717 |
> |
return getFirst(); |
718 |
|
} |
719 |
|
|
720 |
|
public Object poll() { |
721 |
|
if (size==0) |
722 |
|
return null; |
723 |
< |
Object last = header.previous.element; |
722 |
< |
remove(header.previous); |
723 |
< |
return last; |
723 |
> |
return removeFirst(); |
724 |
|
} |
725 |
|
|
726 |
|
public Object remove() { |
727 |
< |
if (size==0) |
728 |
< |
throw new NoSuchElementException(); |
729 |
< |
Object last = header.previous.element; |
730 |
< |
remove(header.previous); |
731 |
< |
return last; |
727 |
> |
return removeFirst(); |
728 |
|
} |
729 |
|
|
730 |
|
public boolean offer(Object x) { |