ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/LinkedList.java
(Generate patch)

Comparing jsr166/src/main/java/util/LinkedList.java (file contents):
Revision 1.1 by tim, Wed May 14 21:30:44 2003 UTC vs.
Revision 1.2 by dl, Thu Aug 7 15:59:46 2003 UTC

# Line 257 | Line 257 | public class LinkedList extends Abstract
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));
# Line 706 | Line 710 | public class LinkedList extends Abstract
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) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines