5 |
|
*/ |
6 |
|
|
7 |
|
package java.util; |
8 |
– |
import java.util.*; // for javadoc (till 6280605 is fixed) |
8 |
|
|
9 |
|
/** |
10 |
|
* This class provides skeletal implementations of some {@link Queue} |
12 |
|
* the base implementation does <em>not</em> allow <tt>null</tt> |
13 |
|
* elements. Methods {@link #add add}, {@link #remove remove}, and |
14 |
|
* {@link #element element} are based on {@link #offer offer}, {@link |
15 |
< |
* #poll poll}, and {@link #peek peek}, respectively but throw |
15 |
> |
* #poll poll}, and {@link #peek peek}, respectively, but throw |
16 |
|
* exceptions instead of indicating failure via <tt>false</tt> or |
17 |
|
* <tt>null</tt> returns. |
18 |
|
* |
19 |
< |
* <p> A <tt>Queue</tt> implementation that extends this class must |
19 |
> |
* <p>A <tt>Queue</tt> implementation that extends this class must |
20 |
|
* minimally define a method {@link Queue#offer} which does not permit |
21 |
|
* insertion of <tt>null</tt> elements, along with methods {@link |
22 |
< |
* Queue#peek}, {@link Queue#poll}, {@link Collection#size}, and a |
23 |
< |
* {@link Collection#iterator} supporting {@link |
24 |
< |
* Iterator#remove}. Typically, additional methods will be overridden |
25 |
< |
* as well. If these requirements cannot be met, consider instead |
27 |
< |
* subclassing {@link AbstractCollection}. |
22 |
> |
* Queue#peek}, {@link Queue#poll}, {@link Collection#size}, and |
23 |
> |
* {@link Collection#iterator}. Typically, additional methods will be |
24 |
> |
* overridden as well. If these requirements cannot be met, consider |
25 |
> |
* instead subclassing {@link AbstractCollection}. |
26 |
|
* |
27 |
|
* <p>This class is a member of the |
28 |
< |
* <a href="{@docRoot}/../guide/collections/index.html"> |
28 |
> |
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> |
29 |
|
* Java Collections Framework</a>. |
30 |
|
* |
31 |
|
* @since 1.5 |
58 |
|
* @throws ClassCastException if the class of the specified element |
59 |
|
* prevents it from being added to this queue |
60 |
|
* @throws NullPointerException if the specified element is null and |
61 |
< |
* this queue not permit null elements |
61 |
> |
* this queue does not permit null elements |
62 |
|
* @throws IllegalArgumentException if some property of this element |
63 |
|
* prevents it from being added to this queue |
64 |
|
*/ |
154 |
|
if (c == this) |
155 |
|
throw new IllegalArgumentException(); |
156 |
|
boolean modified = false; |
157 |
< |
Iterator<? extends E> e = c.iterator(); |
158 |
< |
while (e.hasNext()) { |
161 |
< |
if (add(e.next())) |
157 |
> |
for (E e : c) |
158 |
> |
if (add(e)) |
159 |
|
modified = true; |
163 |
– |
} |
160 |
|
return modified; |
161 |
|
} |
162 |
|
|