105 |
|
* @return <tt>true</tt> (as per the general contract of |
106 |
|
* <tt>Collection.add</tt>). |
107 |
|
* |
108 |
< |
* @throws NullPointerException {@inheritDoc} |
108 |
> |
* @throws NullPointerException if the specified element is <tt>null</tt>. |
109 |
|
* @throws ClassCastException if the specified element cannot be compared |
110 |
|
* with elements currently in the priority queue according |
111 |
|
* to the priority queue's ordering. |
123 |
|
* <p> |
124 |
|
* This implementation iterates over the specified collection, and adds |
125 |
|
* each object returned by the iterator to this collection, in turn. |
126 |
< |
* @throws NullPointerException {@inheritDoc} |
126 |
> |
* @param c collection whose elements are to be added to this queue |
127 |
> |
* @return <tt>true</tt> if this queue changed as a result of the |
128 |
> |
* call. |
129 |
> |
* @throws NullPointerException if <tt>c</tt> or any element in <tt>c</tt> |
130 |
> |
* is <tt>null</tt> |
131 |
|
* @throws ClassCastException if any element cannot be compared |
132 |
|
* with elements currently in the priority queue according |
133 |
|
* to the priority queue's ordering. |
149 |
|
} |
150 |
|
|
151 |
|
/** |
152 |
< |
* Adds the specified element to this priority queue. |
152 |
> |
* Inserts the specified element to this priority queue. |
153 |
|
* |
154 |
+ |
* @param o the element to add |
155 |
|
* @return <tt>true</tt> |
156 |
|
* @throws ClassCastException if the specified element cannot be compared |
157 |
|
* with elements currently in the priority queue according |
158 |
|
* to the priority queue's ordering. |
159 |
< |
* @throws NullPointerException {@inheritDoc} |
159 |
> |
* @throws NullPointerException if the specified element is <tt>null</tt>. |
160 |
|
*/ |
161 |
|
public boolean offer(E o) { |
162 |
|
if (o == null) throw new NullPointerException(); |
174 |
|
/** |
175 |
|
* Adds the specified element to this priority queue. As the queue is |
176 |
|
* unbounded this method will never block. |
177 |
+ |
* @param o the element to add |
178 |
|
* @throws ClassCastException if the element cannot be compared |
179 |
|
* with elements currently in the priority queue according |
180 |
|
* to the priority queue's ordering. |
181 |
< |
* @throws NullPointerException {@inheritDoc} |
181 |
> |
* @throws NullPointerException if the specified element is <tt>null</tt>. |
182 |
|
*/ |
183 |
|
public void put(E o) { |
184 |
|
offer(o); // never need to block |
187 |
|
/** |
188 |
|
* Adds the specified element to this priority queue. As the queue is |
189 |
|
* unbounded this method will never block. |
190 |
< |
* @param o {@inheritDoc} |
190 |
> |
* @param o the element to add |
191 |
|
* @param timeout This parameter is ignored as the method never blocks |
192 |
|
* @param unit This parameter is ignored as the method never blocks |
193 |
+ |
* @return <tt>true</tt> |
194 |
|
* @throws ClassCastException if the element cannot be compared |
195 |
|
* with elements currently in the priority queue according |
196 |
|
* to the priority queue's ordering. |
197 |
< |
* @throws NullPointerException {@inheritDoc} |
191 |
< |
* @return <tt>true</tt> |
197 |
> |
* @throws NullPointerException if the specified element is <tt>null</tt>. |
198 |
|
*/ |
199 |
|
public boolean offer(E o, long timeout, TimeUnit unit) { |
200 |
|
return offer(o); // never need to block |
277 |
|
return Integer.MAX_VALUE; |
278 |
|
} |
279 |
|
|
274 |
– |
/** |
275 |
– |
* Removes a single instance of the specified element from this |
276 |
– |
* queue, if it is present. More formally, |
277 |
– |
* removes an element <tt>e</tt> such that <tt>(o==null ? e==null : |
278 |
– |
* o.equals(e))</tt>, if the queue contains one or more such |
279 |
– |
* elements. Returns <tt>true</tt> if the queue contained the |
280 |
– |
* specified element (or equivalently, if the queue changed as a |
281 |
– |
* result of the call). |
282 |
– |
* |
283 |
– |
* <p>This implementation iterates over the queue looking for the |
284 |
– |
* specified element. If it finds the element, it removes the element |
285 |
– |
* from the queue using the iterator's remove method.<p> |
286 |
– |
* |
287 |
– |
*/ |
280 |
|
public boolean remove(Object o) { |
281 |
|
lock.lock(); |
282 |
|
try { |