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

Comparing jsr166/src/main/java/util/AbstractQueue.java (file contents):
Revision 1.18 by dl, Fri Sep 26 11:37:06 2003 UTC vs.
Revision 1.25 by dl, Tue Jan 27 11:36:26 2004 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3 < * Expert Group and released to the public domain. Use, modify, and
4 < * redistribute this code in any way without acknowledgement.
3 > * Expert Group and released to the public domain, as explained at
4 > * http://creativecommons.org/licenses/publicdomain
5   */
6  
7   package java.util;
# Line 25 | Line 25 | package java.util;
25   * as well. If these requirements cannot be met, consider instead
26   * subclassing {@link AbstractCollection}.
27   *
28 + * <p>This class is a member of the
29 + * <a href="{@docRoot}/../guide/collections/index.html">
30 + * Java Collections Framework</a>.
31 + *  
32   * @since 1.5
33   * @author Doug Lea
34 + * @param <E> the type of elements held in this collection
35   */
36   public abstract class AbstractQueue<E>
37      extends AbstractCollection<E>
# Line 101 | Line 106 | public abstract class AbstractQueue<E>
106          while (poll() != null)
107              ;
108      }
109 +
110 +    /**
111 +     * Adds all of the elements in the specified collection to this
112 +     * queue.  Attempts to addAll of a queue to itself result in
113 +     * <tt>IllegalArgumentException</tt>. Further, the behavior of
114 +     * this operation is undefined if the specified collection is
115 +     * modified while the operation is in progress.
116 +     *
117 +     * <p>This implementation iterates over the specified collection,
118 +     * and adds each element returned by the iterator to this
119 +     * collection, in turn.  A runtime exception encountered while
120 +     * trying to add an element (including, in particular, a
121 +     * <tt>null</tt> element) may result in only some of the elements
122 +     * having been successfully added when the associated exception is
123 +     * thrown.
124 +     *
125 +     * @param c collection whose elements are to be added to this collection.
126 +     * @return <tt>true</tt> if this collection changed as a result of the
127 +     *         call.
128 +     * @throws NullPointerException if the specified collection or
129 +     * any of its elements are null.
130 +     * @throws IllegalArgumentException if c is this queue.
131 +     *
132 +     * @see #add(Object)
133 +     */
134 +    public boolean addAll(Collection<? extends E> c) {
135 +        if (c == null)
136 +            throw new NullPointerException();
137 +        if (c == this)
138 +            throw new IllegalArgumentException();
139 +        boolean modified = false;
140 +        Iterator<? extends E> e = c.iterator();
141 +        while (e.hasNext()) {
142 +            if (add(e.next()))
143 +                modified = true;
144 +        }
145 +        return modified;
146 +    }
147 +
148   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines