5 |
|
*/ |
6 |
|
|
7 |
|
package java.util; |
8 |
+ |
import java.util.*; // for javadoc |
9 |
|
|
10 |
|
/** |
11 |
|
* A linear collection that supports element insertion and removal at |
173 |
|
* @param e the element to add |
174 |
|
* @throws IllegalStateException if the element cannot be added at this |
175 |
|
* time due to capacity restrictions |
175 |
– |
* @throws NullPointerException if the specified element is null and this |
176 |
– |
* deque does not permit null elements |
176 |
|
* @throws ClassCastException if the class of the specified element |
177 |
|
* prevents it from being added to this deque |
178 |
+ |
* @throws NullPointerException if the specified element is null and this |
179 |
+ |
* deque does not permit null elements |
180 |
|
* @throws IllegalArgumentException if some property of the specified |
181 |
|
* element prevents it from being added to this deque |
182 |
|
*/ |
183 |
|
void addFirst(E e); |
184 |
|
|
185 |
|
/** |
186 |
< |
* Inserts the specified element at the end of this deque if it is |
186 |
> |
* Inserts the specified element at the end of this deque if it is |
187 |
|
* possible to do so immediately without violating capacity restrictions. |
188 |
|
* When using a capacity-restricted deque, it is generally preferable to |
189 |
|
* use method {@link #offerLast}. |
190 |
|
* |
191 |
+ |
* <p>This method is equivalent to {@link #add}. |
192 |
+ |
* |
193 |
|
* @param e the element to add |
194 |
|
* @throws IllegalStateException if the element cannot be added at this |
195 |
|
* time due to capacity restrictions |
193 |
– |
* @throws NullPointerException if the specified element is null and this |
194 |
– |
* deque does not permit null elements |
196 |
|
* @throws ClassCastException if the class of the specified element |
197 |
|
* prevents it from being added to this deque |
198 |
+ |
* @throws NullPointerException if the specified element is null and this |
199 |
+ |
* deque does not permit null elements |
200 |
|
* @throws IllegalArgumentException if some property of the specified |
201 |
|
* element prevents it from being added to this deque |
202 |
|
*/ |
209 |
|
* which can fail to insert an element only by throwing an exception. |
210 |
|
* |
211 |
|
* @param e the element to add |
212 |
< |
* @return <tt>true</tt> if it was possible to insert the element, |
213 |
< |
* else <tt>false</tt> |
211 |
< |
* @throws NullPointerException if the specified element is null and this |
212 |
< |
* deque does not permit null elements |
212 |
> |
* @return <tt>true</tt> if the element was added to this deque, else |
213 |
> |
* <tt>false</tt> |
214 |
|
* @throws ClassCastException if the class of the specified element |
215 |
|
* prevents it from being added to this deque |
216 |
+ |
* @throws NullPointerException if the specified element is null and this |
217 |
+ |
* deque does not permit null elements |
218 |
|
* @throws IllegalArgumentException if some property of the specified |
219 |
|
* element prevents it from being added to this deque |
220 |
|
*/ |
227 |
|
* which can fail to insert an element only by throwing an exception. |
228 |
|
* |
229 |
|
* @param e the element to add |
230 |
< |
* @return <tt>true</tt> if it was possible to insert the element, |
231 |
< |
* else <tt>false</tt> |
229 |
< |
* @throws NullPointerException if the specified element is null and this |
230 |
< |
* deque does not permit null elements |
230 |
> |
* @return <tt>true</tt> if the element was added to this deque, else |
231 |
> |
* <tt>false</tt> |
232 |
|
* @throws ClassCastException if the class of the specified element |
233 |
|
* prevents it from being added to this deque |
234 |
+ |
* @throws NullPointerException if the specified element is null and this |
235 |
+ |
* deque does not permit null elements |
236 |
|
* @throws IllegalArgumentException if some property of the specified |
237 |
|
* element prevents it from being added to this deque |
238 |
|
*/ |
314 |
|
* Removes the first occurrence of the specified element from this deque. |
315 |
|
* If the deque does not contain the element, it is unchanged. |
316 |
|
* More formally, removes the first element <tt>e</tt> such that |
317 |
< |
* <tt>(o==null ? e==null : o.equals(e))</tt> (if such an element exists). |
318 |
< |
* Returns true if this deque contained the specified element (or |
319 |
< |
* equivalently, if this deque changed as a result of the call). |
317 |
> |
* <tt>(o==null ? e==null : o.equals(e))</tt> |
318 |
> |
* (if such an element exists). |
319 |
> |
* Returns <tt>true</tt> if this deque contained the specified element |
320 |
> |
* (or equivalently, if this deque changed as a result of the call). |
321 |
|
* |
322 |
|
* @param o element to be removed from this deque, if present |
323 |
|
* @return <tt>true</tt> if an element was removed as a result of this call |
324 |
+ |
* @throws ClassCastException if the class of the specified element |
325 |
+ |
* is incompatible with this deque (optional) |
326 |
|
* @throws NullPointerException if the specified element is null and this |
327 |
|
* deque does not permit null elements (optional) |
322 |
– |
* @throws ClassCastException if the class of the specified element |
323 |
– |
* is incompatible with this collection (optional) |
328 |
|
*/ |
329 |
|
boolean removeFirstOccurrence(Object o); |
330 |
|
|
332 |
|
* Removes the last occurrence of the specified element from this deque. |
333 |
|
* If the deque does not contain the element, it is unchanged. |
334 |
|
* More formally, removes the last element <tt>e</tt> such that |
335 |
< |
* <tt>(o==null ? e==null : o.equals(e))</tt> (if such an element exists). |
336 |
< |
* Returns true if this deque contained the specified element (or |
337 |
< |
* equivalently, if this deque changed as a result of the call). |
335 |
> |
* <tt>(o==null ? e==null : o.equals(e))</tt> |
336 |
> |
* (if such an element exists). |
337 |
> |
* Returns <tt>true</tt> if this deque contained the specified element |
338 |
> |
* (or equivalently, if this deque changed as a result of the call). |
339 |
|
* |
340 |
|
* @param o element to be removed from this deque, if present |
341 |
|
* @return <tt>true</tt> if an element was removed as a result of this call |
342 |
+ |
* @throws ClassCastException if the class of the specified element |
343 |
+ |
* is incompatible with this deque (optional) |
344 |
|
* @throws NullPointerException if the specified element is null and this |
345 |
|
* deque does not permit null elements (optional) |
339 |
– |
* @throws ClassCastException if the class of the specified element |
340 |
– |
* is incompatible with this collection (optional) |
346 |
|
*/ |
347 |
|
boolean removeLastOccurrence(Object o); |
348 |
|
|
357 |
|
* When using a capacity-restricted deque, it is generally preferable to |
358 |
|
* use {@link #offer(Object) offer}. |
359 |
|
* |
360 |
< |
* <p>This method is equivalent to {@link #addLast(Object) addLast}. |
360 |
> |
* <p>This method is equivalent to {@link #addLast}. |
361 |
|
* |
362 |
|
* @param e the element to add |
363 |
|
* @return <tt>true</tt> (as per the spec for {@link Collection#add}) |
364 |
|
* @throws IllegalStateException if the element cannot be added at this |
365 |
|
* time due to capacity restrictions |
361 |
– |
* @throws NullPointerException if the specified element is null and this |
362 |
– |
* deque does not permit null elements |
366 |
|
* @throws ClassCastException if the class of the specified element |
367 |
|
* prevents it from being added to this deque |
368 |
+ |
* @throws NullPointerException if the specified element is null and this |
369 |
+ |
* deque does not permit null elements |
370 |
|
* @throws IllegalArgumentException if some property of the specified |
371 |
|
* element prevents it from being added to this deque |
372 |
|
*/ |
386 |
|
* @param e the element to add |
387 |
|
* @return <tt>true</tt> if the element was added to this deque, else |
388 |
|
* <tt>false</tt> |
384 |
– |
* @throws NullPointerException if the specified element is null and this |
385 |
– |
* deque does not permit null elements |
389 |
|
* @throws ClassCastException if the class of the specified element |
390 |
|
* prevents it from being added to this deque |
391 |
+ |
* @throws NullPointerException if the specified element is null and this |
392 |
+ |
* deque does not permit null elements |
393 |
|
* @throws IllegalArgumentException if some property of the specified |
394 |
|
* element prevents it from being added to this deque |
395 |
|
*/ |
460 |
|
* @param e the element to push |
461 |
|
* @throws IllegalStateException if the element cannot be added at this |
462 |
|
* time due to capacity restrictions |
458 |
– |
* @throws NullPointerException if the specified element is null and this |
459 |
– |
* deque does not permit null elements |
463 |
|
* @throws ClassCastException if the class of the specified element |
464 |
|
* prevents it from being added to this deque |
465 |
+ |
* @throws NullPointerException if the specified element is null and this |
466 |
+ |
* deque does not permit null elements |
467 |
|
* @throws IllegalArgumentException if some property of the specified |
468 |
|
* element prevents it from being added to this deque |
469 |
|
*/ |
488 |
|
* Removes the first occurrence of the specified element from this deque. |
489 |
|
* If the deque does not contain the element, it is unchanged. |
490 |
|
* More formally, removes the first element <tt>e</tt> such that |
491 |
< |
* <tt>(o==null ? e==null : o.equals(e))</tt> (if such an element exists). |
492 |
< |
* Returns true if this deque contained the specified element (or |
493 |
< |
* equivalently, if this deque changed as a result of the call). |
491 |
> |
* <tt>(o==null ? e==null : o.equals(e))</tt> |
492 |
> |
* (if such an element exists). |
493 |
> |
* Returns <tt>true</tt> if this deque contained the specified element |
494 |
> |
* (or equivalently, if this deque changed as a result of the call). |
495 |
|
* |
496 |
|
* <p>This method is equivalent to {@link #removeFirstOccurrence}. |
497 |
|
* |
498 |
|
* @param o element to be removed from this deque, if present |
499 |
|
* @return <tt>true</tt> if an element was removed as a result of this call |
500 |
+ |
* @throws ClassCastException if the class of the specified element |
501 |
+ |
* is incompatible with this deque (optional) |
502 |
|
* @throws NullPointerException if the specified element is null and this |
503 |
|
* deque does not permit null elements (optional) |
496 |
– |
* @throws ClassCastException if the class of the specified element |
497 |
– |
* is incompatible with this collection (optional) |
504 |
|
*/ |
505 |
|
boolean remove(Object o); |
506 |
|
|
507 |
|
/** |
508 |
|
* Returns <tt>true</tt> if this deque contains the specified element. |
509 |
< |
* More formally, returns <tt>true</tt> if and only if this deque |
510 |
< |
* contains at least one element <tt>e</tt> such that <tt>(o==null ? |
511 |
< |
* e==null : o.equals(e))</tt>. |
509 |
> |
* More formally, returns <tt>true</tt> if and only if this deque contains |
510 |
> |
* at least one element <tt>e</tt> such that |
511 |
> |
* <tt>(o==null ? e==null : o.equals(e))</tt>. |
512 |
|
* |
513 |
|
* @param o element whose presence in this deque is to be tested |
514 |
|
* @return <tt>true</tt> if this deque contains the specified element |
527 |
|
public int size(); |
528 |
|
|
529 |
|
/** |
530 |
< |
* Returns an iterator over the elements in this deque. The elements |
531 |
< |
* will be ordered from first (head) to last (tail). |
530 |
> |
* Returns an iterator over the elements in this deque in proper sequence. |
531 |
> |
* The elements will be returned in order from first (head) to last (tail). |
532 |
|
* |
533 |
< |
* @return an <tt>Iterator</tt> over the elements in this deque |
533 |
> |
* @return an iterator over the elements in this deque in proper sequence |
534 |
|
*/ |
535 |
|
Iterator<E> iterator(); |
536 |
|
} |