29 |
|
* |
30 |
|
* <p> |
31 |
|
* <table BORDER CELLPADDING=3 CELLSPACING=1> |
32 |
+ |
* <caption>Summary of Deque methods</caption> |
33 |
|
* <tr> |
34 |
|
* <td></td> |
35 |
|
* <td ALIGN=CENTER COLSPAN = 2> <b>First Element (Head)</b></td> |
44 |
|
* </tr> |
45 |
|
* <tr> |
46 |
|
* <td><b>Insert</b></td> |
47 |
< |
* <td>{@link #addFirst addFirst(e)}</td> |
48 |
< |
* <td>{@link #offerFirst offerFirst(e)}</td> |
49 |
< |
* <td>{@link #addLast addLast(e)}</td> |
50 |
< |
* <td>{@link #offerLast offerLast(e)}</td> |
47 |
> |
* <td>{@link Deque#addFirst addFirst(e)}</td> |
48 |
> |
* <td>{@link Deque#offerFirst offerFirst(e)}</td> |
49 |
> |
* <td>{@link Deque#addLast addLast(e)}</td> |
50 |
> |
* <td>{@link Deque#offerLast offerLast(e)}</td> |
51 |
|
* </tr> |
52 |
|
* <tr> |
53 |
|
* <td><b>Remove</b></td> |
54 |
< |
* <td>{@link #removeFirst removeFirst()}</td> |
55 |
< |
* <td>{@link #pollFirst pollFirst()}</td> |
56 |
< |
* <td>{@link #removeLast removeLast()}</td> |
57 |
< |
* <td>{@link #pollLast pollLast()}</td> |
54 |
> |
* <td>{@link Deque#removeFirst removeFirst()}</td> |
55 |
> |
* <td>{@link Deque#pollFirst pollFirst()}</td> |
56 |
> |
* <td>{@link Deque#removeLast removeLast()}</td> |
57 |
> |
* <td>{@link Deque#pollLast pollLast()}</td> |
58 |
|
* </tr> |
59 |
|
* <tr> |
60 |
|
* <td><b>Examine</b></td> |
61 |
< |
* <td>{@link #getFirst getFirst()}</td> |
62 |
< |
* <td>{@link #peekFirst peekFirst()}</td> |
63 |
< |
* <td>{@link #getLast getLast()}</td> |
64 |
< |
* <td>{@link #peekLast peekLast()}</td> |
61 |
> |
* <td>{@link Deque#getFirst getFirst()}</td> |
62 |
> |
* <td>{@link Deque#peekFirst peekFirst()}</td> |
63 |
> |
* <td>{@link Deque#getLast getLast()}</td> |
64 |
> |
* <td>{@link Deque#peekLast peekLast()}</td> |
65 |
|
* </tr> |
66 |
|
* </table> |
67 |
|
* |
73 |
|
* |
74 |
|
* <p> |
75 |
|
* <table BORDER CELLPADDING=3 CELLSPACING=1> |
76 |
+ |
* <caption>Comparison of Queue and Deque methods</caption> |
77 |
|
* <tr> |
78 |
|
* <td ALIGN=CENTER> <b>{@code Queue} Method</b></td> |
79 |
|
* <td ALIGN=CENTER> <b>Equivalent {@code Deque} Method</b></td> |
112 |
|
* |
113 |
|
* <p> |
114 |
|
* <table BORDER CELLPADDING=3 CELLSPACING=1> |
115 |
+ |
* <caption>Comparison of Stack and Deque methods</caption> |
116 |
|
* <tr> |
117 |
|
* <td ALIGN=CENTER> <b>Stack Method</b></td> |
118 |
|
* <td ALIGN=CENTER> <b>Equivalent {@code Deque} Method</b></td> |
167 |
|
public interface Deque<E> extends Queue<E> { |
168 |
|
/** |
169 |
|
* Inserts the specified element at the front of this deque if it is |
170 |
< |
* possible to do so immediately without violating capacity restrictions. |
171 |
< |
* When using a capacity-restricted deque, it is generally preferable to |
172 |
< |
* use method {@link #offerFirst}. |
170 |
> |
* possible to do so immediately without violating capacity restrictions, |
171 |
> |
* throwing an {@code IllegalStateException} if no space is currently |
172 |
> |
* available. When using a capacity-restricted deque, it is generally |
173 |
> |
* preferable to use method {@link #offerFirst}. |
174 |
|
* |
175 |
|
* @param e the element to add |
176 |
|
* @throws IllegalStateException if the element cannot be added at this |
186 |
|
|
187 |
|
/** |
188 |
|
* Inserts the specified element at the end of this deque if it is |
189 |
< |
* possible to do so immediately without violating capacity restrictions. |
190 |
< |
* When using a capacity-restricted deque, it is generally preferable to |
191 |
< |
* use method {@link #offerLast}. |
189 |
> |
* possible to do so immediately without violating capacity restrictions, |
190 |
> |
* throwing an {@code IllegalStateException} if no space is currently |
191 |
> |
* available. When using a capacity-restricted deque, it is generally |
192 |
> |
* preferable to use method {@link #offerLast}. |
193 |
|
* |
194 |
|
* <p>This method is equivalent to {@link #add}. |
195 |
|
* |
326 |
|
* @param o element to be removed from this deque, if present |
327 |
|
* @return {@code true} if an element was removed as a result of this call |
328 |
|
* @throws ClassCastException if the class of the specified element |
329 |
< |
* is incompatible with this deque (optional) |
330 |
< |
* @throws NullPointerException if the specified element is null and this |
331 |
< |
* deque does not permit null elements (optional) |
329 |
> |
* is incompatible with this deque |
330 |
> |
* (<a href="../Collection.html#optional-restrictions">optional</a>) |
331 |
> |
* @throws NullPointerException if the specified element is null |
332 |
> |
* (<a href="../Collection.html#optional-restrictions">optional</a>) |
333 |
|
*/ |
334 |
|
boolean removeFirstOccurrence(Object o); |
335 |
|
|
345 |
|
* @param o element to be removed from this deque, if present |
346 |
|
* @return {@code true} if an element was removed as a result of this call |
347 |
|
* @throws ClassCastException if the class of the specified element |
348 |
< |
* is incompatible with this deque (optional) |
349 |
< |
* @throws NullPointerException if the specified element is null and this |
350 |
< |
* deque does not permit null elements (optional) |
348 |
> |
* is incompatible with this deque |
349 |
> |
* (<a href="../Collection.html#optional-restrictions">optional</a>) |
350 |
> |
* @throws NullPointerException if the specified element is null |
351 |
> |
* (<a href="../Collection.html#optional-restrictions">optional</a>) |
352 |
|
*/ |
353 |
|
boolean removeLastOccurrence(Object o); |
354 |
|
|
457 |
|
/** |
458 |
|
* Pushes an element onto the stack represented by this deque (in other |
459 |
|
* words, at the head of this deque) if it is possible to do so |
460 |
< |
* immediately without violating capacity restrictions, returning |
454 |
< |
* {@code true} upon success and throwing an |
460 |
> |
* immediately without violating capacity restrictions, throwing an |
461 |
|
* {@code IllegalStateException} if no space is currently available. |
462 |
|
* |
463 |
|
* <p>This method is equivalent to {@link #addFirst}. |
503 |
|
* @param o element to be removed from this deque, if present |
504 |
|
* @return {@code true} if an element was removed as a result of this call |
505 |
|
* @throws ClassCastException if the class of the specified element |
506 |
< |
* is incompatible with this deque (optional) |
507 |
< |
* @throws NullPointerException if the specified element is null and this |
508 |
< |
* deque does not permit null elements (optional) |
506 |
> |
* is incompatible with this deque |
507 |
> |
* (<a href="../Collection.html#optional-restrictions">optional</a>) |
508 |
> |
* @throws NullPointerException if the specified element is null |
509 |
> |
* (<a href="../Collection.html#optional-restrictions">optional</a>) |
510 |
|
*/ |
511 |
|
boolean remove(Object o); |
512 |
|
|
518 |
|
* |
519 |
|
* @param o element whose presence in this deque is to be tested |
520 |
|
* @return {@code true} if this deque contains the specified element |
521 |
< |
* @throws ClassCastException if the type of the specified element |
522 |
< |
* is incompatible with this deque (optional) |
523 |
< |
* @throws NullPointerException if the specified element is null and this |
524 |
< |
* deque does not permit null elements (optional) |
521 |
> |
* @throws ClassCastException if the class of the specified element |
522 |
> |
* is incompatible with this deque |
523 |
> |
* (<a href="../Collection.html#optional-restrictions">optional</a>) |
524 |
> |
* @throws NullPointerException if the specified element is null |
525 |
> |
* (<a href="../Collection.html#optional-restrictions">optional</a>) |
526 |
|
*/ |
527 |
|
boolean contains(Object o); |
528 |
|
|