25 |
|
* operations cannot fail. |
26 |
|
* |
27 |
|
* <p>The twelve methods described above are summarized in the |
28 |
< |
* following table:<p> |
28 |
> |
* following table: |
29 |
|
* |
30 |
< |
* <table BORDER CELLPADDING=3 CELLSPACING=1> |
30 |
> |
* <p><table BORDER CELLPADDING=3 CELLSPACING=1> |
31 |
|
* <tr> |
32 |
|
* <td></td> |
33 |
|
* <td ALIGN=CENTER COLSPAN = 2> <b>First Element (Head)</b></td> |
67 |
|
* used as a queue, FIFO (First-In-First-Out) behavior results. Elements are |
68 |
|
* added at the end of the deque and removed from the beginning. The methods |
69 |
|
* inherited from the <tt>Queue</tt> interface are precisely equivalent to |
70 |
< |
* <tt>Deque</tt> methods as indicated in the following table:<p> |
70 |
> |
* <tt>Deque</tt> methods as indicated in the following table: |
71 |
|
* |
72 |
< |
* <table BORDER CELLPADDING=3 CELLSPACING=1> |
72 |
> |
* <p><table BORDER CELLPADDING=3 CELLSPACING=1> |
73 |
|
* <tr> |
74 |
|
* <td ALIGN=CENTER> <b><tt>Queue</tt> Method</b></td> |
75 |
|
* <td ALIGN=CENTER> <b>Equivalent <tt>Deque</tt> Method</b></td> |
76 |
|
* </tr> |
77 |
|
* <tr> |
78 |
– |
* <tr> |
78 |
|
* <td>{@link java.util.Queue#offer offer(e)}</td> |
79 |
|
* <td>{@link #offerLast offerLast(e)}</td> |
80 |
< |
* </tr> |
81 |
< |
* <tr> |
80 |
> |
* </tr> |
81 |
> |
* <tr> |
82 |
|
* <td>{@link java.util.Queue#add add(e)}</td> |
83 |
|
* <td>{@link #addLast addLast(e)}</td> |
84 |
< |
* </tr> |
85 |
< |
* <tr> |
84 |
> |
* </tr> |
85 |
> |
* <tr> |
86 |
|
* <td>{@link java.util.Queue#poll poll()}</td> |
87 |
|
* <td>{@link #pollFirst pollFirst()}</td> |
88 |
< |
* </tr> |
89 |
< |
* <tr> |
88 |
> |
* </tr> |
89 |
> |
* <tr> |
90 |
|
* <td>{@link java.util.Queue#remove remove()}</td> |
91 |
|
* <td>{@link #removeFirst removeFirst()}</td> |
92 |
< |
* </tr> |
93 |
< |
* <tr> |
92 |
> |
* </tr> |
93 |
> |
* <tr> |
94 |
|
* <td>{@link java.util.Queue#peek peek()}</td> |
95 |
|
* <td>{@link #peek peekFirst()}</td> |
96 |
< |
* </tr> |
97 |
< |
* <tr> |
96 |
> |
* </tr> |
97 |
> |
* <tr> |
98 |
|
* <td>{@link java.util.Queue#element element()}</td> |
99 |
|
* <td>{@link #getFirst getFirst()}</td> |
100 |
< |
* </tr> |
100 |
> |
* </tr> |
101 |
|
* </table> |
102 |
|
* |
103 |
|
* <p>Deques can also be used as LIFO (Last-In-First-Out) stacks. This |
104 |
|
* interface should be used in preference to the legacy {@link Stack} class. |
105 |
|
* When a deque is used as a stack, elements are pushed and popped from the |
106 |
|
* beginning of the deque. Stack methods are precisely equivalent to |
107 |
< |
* <tt>Deque</tt> methods as indicated in the table below:<p> |
107 |
> |
* <tt>Deque</tt> methods as indicated in the table below: |
108 |
|
* |
109 |
< |
* <table BORDER CELLPADDING=3 CELLSPACING=1> |
109 |
> |
* <p><table BORDER CELLPADDING=3 CELLSPACING=1> |
110 |
|
* <tr> |
111 |
|
* <td ALIGN=CENTER> <b>Stack Method</b></td> |
112 |
|
* <td ALIGN=CENTER> <b>Equivalent <tt>Deque</tt> Method</b></td> |
113 |
|
* </tr> |
114 |
|
* <tr> |
116 |
– |
* <tr> |
115 |
|
* <td>{@link #push push(e)}</td> |
116 |
|
* <td>{@link #addFirst addFirst(e)}</td> |
117 |
< |
* </tr> |
118 |
< |
* <tr> |
117 |
> |
* </tr> |
118 |
> |
* <tr> |
119 |
|
* <td>{@link #pop pop()}</td> |
120 |
|
* <td>{@link #removeFirst removeFirst()}</td> |
121 |
< |
* </tr> |
122 |
< |
* <tr> |
121 |
> |
* </tr> |
122 |
> |
* <tr> |
123 |
|
* <td>{@link #peek peek()}</td> |
124 |
|
* <td>{@link #peekFirst peekFirst()}</td> |
125 |
< |
* </tr> |
125 |
> |
* </tr> |
126 |
|
* </table> |
127 |
|
* |
128 |
|
* <p>Note that the {@link #peek peek} method works equally well when |
230 |
|
E pollLast(); |
231 |
|
|
232 |
|
/** |
233 |
< |
* Removes and returns the first element of this deque. This method |
233 |
> |
* Retrieves and removes the first element of this deque. This method |
234 |
|
* differs from the <tt>pollFirst</tt> method only in that it throws an |
235 |
|
* exception if this deque is empty. |
236 |
|
* |