1 |
|
/* |
2 |
|
* Written by Doug Lea and Josh Bloch with assistance from members of |
3 |
|
* JCP JSR-166 Expert Group and released to the public domain, as explained |
4 |
< |
* at http://creativecommons.org/licenses/publicdomain |
4 |
> |
* at http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
package java.util; |
9 |
|
/** |
10 |
|
* A linear collection that supports element insertion and removal at |
11 |
|
* both ends. The name <i>deque</i> is short for "double ended queue" |
12 |
< |
* and is usually pronounced "deck". Most <tt>Deque</tt> |
12 |
> |
* and is usually pronounced "deck". Most {@code Deque} |
13 |
|
* implementations place no fixed limits on the number of elements |
14 |
|
* they may contain, but this interface supports capacity-restricted |
15 |
|
* deques as well as those with no fixed size limit. |
18 |
|
* ends of the deque. Methods are provided to insert, remove, and |
19 |
|
* examine the element. Each of these methods exists in two forms: |
20 |
|
* one throws an exception if the operation fails, the other returns a |
21 |
< |
* special value (either <tt>null</tt> or <tt>false</tt>, depending on |
21 |
> |
* special value (either {@code null} or {@code false}, depending on |
22 |
|
* the operation). The latter form of the insert operation is |
23 |
|
* designed specifically for use with capacity-restricted |
24 |
< |
* <tt>Deque</tt> implementations; in most implementations, insert |
24 |
> |
* {@code Deque} implementations; in most implementations, insert |
25 |
|
* operations cannot fail. |
26 |
|
* |
27 |
|
* <p>The twelve methods described above are summarized in the |
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 |
|
* |
68 |
|
* <p>This interface extends the {@link Queue} interface. When a deque is |
69 |
|
* used as a queue, FIFO (First-In-First-Out) behavior results. Elements are |
70 |
|
* added at the end of the deque and removed from the beginning. The methods |
71 |
< |
* inherited from the <tt>Queue</tt> interface are precisely equivalent to |
72 |
< |
* <tt>Deque</tt> methods as indicated in the following table: |
71 |
> |
* inherited from the {@code Queue} interface are precisely equivalent to |
72 |
> |
* {@code Deque} methods as indicated in the following table: |
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><tt>Queue</tt> Method</b></td> |
79 |
< |
* <td ALIGN=CENTER> <b>Equivalent <tt>Deque</tt> Method</b></td> |
78 |
> |
* <td ALIGN=CENTER> <b>{@code Queue} Method</b></td> |
79 |
> |
* <td ALIGN=CENTER> <b>Equivalent {@code Deque} Method</b></td> |
80 |
|
* </tr> |
81 |
|
* <tr> |
82 |
|
* <td>{@link java.util.Queue#add add(e)}</td> |
108 |
|
* interface should be used in preference to the legacy {@link Stack} class. |
109 |
|
* When a deque is used as a stack, elements are pushed and popped from the |
110 |
|
* beginning of the deque. Stack methods are precisely equivalent to |
111 |
< |
* <tt>Deque</tt> methods as indicated in the table below: |
111 |
> |
* {@code Deque} methods as indicated in the table below: |
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 <tt>Deque</tt> Method</b></td> |
118 |
> |
* <td ALIGN=CENTER> <b>Equivalent {@code Deque} Method</b></td> |
119 |
|
* </tr> |
120 |
|
* <tr> |
121 |
|
* <td>{@link #push push(e)}</td> |
142 |
|
* <p>Unlike the {@link List} interface, this interface does not |
143 |
|
* provide support for indexed access to elements. |
144 |
|
* |
145 |
< |
* <p>While <tt>Deque</tt> implementations are not strictly required |
145 |
> |
* <p>While {@code Deque} implementations are not strictly required |
146 |
|
* to prohibit the insertion of null elements, they are strongly |
147 |
< |
* encouraged to do so. Users of any <tt>Deque</tt> implementations |
147 |
> |
* encouraged to do so. Users of any {@code Deque} implementations |
148 |
|
* that do allow null elements are strongly encouraged <i>not</i> to |
149 |
|
* take advantage of the ability to insert nulls. This is so because |
150 |
< |
* <tt>null</tt> is used as a special return value by various methods |
150 |
> |
* {@code null} is used as a special return value by various methods |
151 |
|
* to indicated that the deque is empty. |
152 |
|
* |
153 |
< |
* <p><tt>Deque</tt> implementations generally do not define |
154 |
< |
* element-based versions of the <tt>equals</tt> and <tt>hashCode</tt> |
153 |
> |
* <p>{@code Deque} implementations generally do not define |
154 |
> |
* element-based versions of the {@code equals} and {@code hashCode} |
155 |
|
* methods, but instead inherit the identity-based versions from class |
156 |
< |
* <tt>Object</tt>. |
156 |
> |
* {@code Object}. |
157 |
|
* |
158 |
|
* <p>This interface is a member of the <a |
159 |
< |
* href="{@docRoot}/../guide/collections/index.html"> Java Collections |
159 |
> |
* href="{@docRoot}/../technotes/guides/collections/index.html"> Java Collections |
160 |
|
* Framework</a>. |
161 |
|
* |
162 |
|
* @author Doug Lea |
164 |
|
* @since 1.6 |
165 |
|
* @param <E> the type of elements held in this collection |
166 |
|
*/ |
164 |
– |
|
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 |
185 |
|
void addFirst(E e); |
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}. |
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 |
> |
* 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 |
|
* |
196 |
|
* @param e the element to add |
197 |
|
* @throws IllegalStateException if the element cannot be added at this |
212 |
|
* which can fail to insert an element only by throwing an exception. |
213 |
|
* |
214 |
|
* @param e the element to add |
215 |
< |
* @return <tt>true</tt> if the element was added to this deque, else |
216 |
< |
* <tt>false</tt> |
215 |
> |
* @return {@code true} if the element was added to this deque, else |
216 |
> |
* {@code false} |
217 |
|
* @throws ClassCastException if the class of the specified element |
218 |
|
* prevents it from being added to this deque |
219 |
|
* @throws NullPointerException if the specified element is null and this |
230 |
|
* which can fail to insert an element only by throwing an exception. |
231 |
|
* |
232 |
|
* @param e the element to add |
233 |
< |
* @return <tt>true</tt> if the element was added to this deque, else |
234 |
< |
* <tt>false</tt> |
233 |
> |
* @return {@code true} if the element was added to this deque, else |
234 |
> |
* {@code false} |
235 |
|
* @throws ClassCastException if the class of the specified element |
236 |
|
* prevents it from being added to this deque |
237 |
|
* @throws NullPointerException if the specified element is null and this |
243 |
|
|
244 |
|
/** |
245 |
|
* Retrieves and removes the first element of this deque. This method |
246 |
< |
* differs from {@link #pollFirst} only in that it throws an exception |
247 |
< |
* if this deque is empty. |
246 |
> |
* differs from {@link #pollFirst pollFirst} only in that it throws an |
247 |
> |
* exception if this deque is empty. |
248 |
|
* |
249 |
|
* @return the head of this deque |
250 |
|
* @throws NoSuchElementException if this deque is empty |
253 |
|
|
254 |
|
/** |
255 |
|
* Retrieves and removes the last element of this deque. This method |
256 |
< |
* differs from {@link #pollLast} only in that it throws an exception if |
257 |
< |
* this deque is empty. |
256 |
> |
* differs from {@link #pollLast pollLast} only in that it throws an |
257 |
> |
* exception if this deque is empty. |
258 |
|
* |
259 |
|
* @return the tail of this deque |
260 |
|
* @throws NoSuchElementException if this deque is empty |
263 |
|
|
264 |
|
/** |
265 |
|
* Retrieves and removes the first element of this deque, |
266 |
< |
* or returns <tt>null</tt> if this deque is empty. |
266 |
> |
* or returns {@code null} if this deque is empty. |
267 |
|
* |
268 |
< |
* @return the head of this deque, or <tt>null</tt> if this deque is empty |
268 |
> |
* @return the head of this deque, or {@code null} if this deque is empty |
269 |
|
*/ |
270 |
|
E pollFirst(); |
271 |
|
|
272 |
|
/** |
273 |
|
* Retrieves and removes the last element of this deque, |
274 |
< |
* or returns <tt>null</tt> if this deque is empty. |
274 |
> |
* or returns {@code null} if this deque is empty. |
275 |
|
* |
276 |
< |
* @return the tail of this deque, or <tt>null</tt> if this deque is empty |
276 |
> |
* @return the tail of this deque, or {@code null} if this deque is empty |
277 |
|
*/ |
278 |
|
E pollLast(); |
279 |
|
|
280 |
|
/** |
281 |
|
* Retrieves, but does not remove, the first element of this deque. |
282 |
< |
* This method differs from {@link #peekFirst} only in that it throws an |
283 |
< |
* exception if this deque is empty. |
282 |
> |
* |
283 |
> |
* This method differs from {@link #peekFirst peekFirst} only in that it |
284 |
> |
* throws an exception if this deque is empty. |
285 |
|
* |
286 |
|
* @return the head of this deque |
287 |
|
* @throws NoSuchElementException if this deque is empty |
290 |
|
|
291 |
|
/** |
292 |
|
* Retrieves, but does not remove, the last element of this deque. |
293 |
< |
* This method differs from {@link #peekLast} only in that it throws an |
294 |
< |
* exception if this deque is empty. |
293 |
> |
* This method differs from {@link #peekLast peekLast} only in that it |
294 |
> |
* throws an exception if this deque is empty. |
295 |
|
* |
296 |
|
* @return the tail of this deque |
297 |
|
* @throws NoSuchElementException if this deque is empty |
300 |
|
|
301 |
|
/** |
302 |
|
* Retrieves, but does not remove, the first element of this deque, |
303 |
< |
* or returns <tt>null</tt> if this deque is empty. |
303 |
> |
* or returns {@code null} if this deque is empty. |
304 |
|
* |
305 |
< |
* @return the head of this deque, or <tt>null</tt> if this deque is empty |
305 |
> |
* @return the head of this deque, or {@code null} if this deque is empty |
306 |
|
*/ |
307 |
|
E peekFirst(); |
308 |
|
|
309 |
|
/** |
310 |
|
* Retrieves, but does not remove, the last element of this deque, |
311 |
< |
* or returns <tt>null</tt> if this deque is empty. |
311 |
> |
* or returns {@code null} if this deque is empty. |
312 |
|
* |
313 |
< |
* @return the tail of this deque, or <tt>null</tt> if this deque is empty |
313 |
> |
* @return the tail of this deque, or {@code null} if this deque is empty |
314 |
|
*/ |
315 |
|
E peekLast(); |
316 |
|
|
317 |
|
/** |
318 |
|
* Removes the first occurrence of the specified element from this deque. |
319 |
|
* If the deque does not contain the element, it is unchanged. |
320 |
< |
* More formally, removes the first element <tt>e</tt> such that |
320 |
> |
* More formally, removes the first element {@code e} such that |
321 |
|
* <tt>(o==null ? e==null : o.equals(e))</tt> |
322 |
|
* (if such an element exists). |
323 |
< |
* Returns true if this deque contained the specified element (or |
324 |
< |
* equivalently, if this deque changed as a result of the call). |
323 |
> |
* Returns {@code true} if this deque contained the specified element |
324 |
> |
* (or equivalently, if this deque changed as a result of the call). |
325 |
|
* |
326 |
|
* @param o element to be removed from this deque, if present |
327 |
< |
* @return <tt>true</tt> if an element was removed as a result of this call |
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 |
|
|
336 |
|
/** |
337 |
|
* Removes the last occurrence of the specified element from this deque. |
338 |
|
* If the deque does not contain the element, it is unchanged. |
339 |
< |
* More formally, removes the last element <tt>e</tt> such that |
339 |
> |
* More formally, removes the last element {@code e} such that |
340 |
|
* <tt>(o==null ? e==null : o.equals(e))</tt> |
341 |
|
* (if such an element exists). |
342 |
< |
* Returns true if this deque contained the specified element (or |
343 |
< |
* equivalently, if this deque changed as a result of the call). |
342 |
> |
* Returns {@code true} if this deque contained the specified element |
343 |
> |
* (or equivalently, if this deque changed as a result of the call). |
344 |
|
* |
345 |
|
* @param o element to be removed from this deque, if present |
346 |
< |
* @return <tt>true</tt> if an element was removed as a result of this call |
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 |
|
|
358 |
|
* Inserts the specified element into the queue represented by this deque |
359 |
|
* (in other words, at the tail of this deque) if it is possible to do so |
360 |
|
* immediately without violating capacity restrictions, returning |
361 |
< |
* <tt>true</tt> upon success and throwing an |
362 |
< |
* <tt>IllegalStateException</tt> if no space is currently available. |
361 |
> |
* {@code true} upon success and throwing an |
362 |
> |
* {@code IllegalStateException} if no space is currently available. |
363 |
|
* When using a capacity-restricted deque, it is generally preferable to |
364 |
|
* use {@link #offer(Object) offer}. |
365 |
|
* |
366 |
< |
* <p>This method is equivalent to {@link #addLast(Object) addLast}. |
366 |
> |
* <p>This method is equivalent to {@link #addLast}. |
367 |
|
* |
368 |
|
* @param e the element to add |
369 |
< |
* @return <tt>true</tt> (as per the spec for {@link Collection#add}) |
369 |
> |
* @return {@code true} (as specified by {@link Collection#add}) |
370 |
|
* @throws IllegalStateException if the element cannot be added at this |
371 |
|
* time due to capacity restrictions |
372 |
|
* @throws ClassCastException if the class of the specified element |
382 |
|
* Inserts the specified element into the queue represented by this deque |
383 |
|
* (in other words, at the tail of this deque) if it is possible to do so |
384 |
|
* immediately without violating capacity restrictions, returning |
385 |
< |
* <tt>true</tt> upon success and <tt>false</tt> if no space is currently |
385 |
> |
* {@code true} upon success and {@code false} if no space is currently |
386 |
|
* available. When using a capacity-restricted deque, this method is |
387 |
|
* generally preferable to the {@link #add} method, which can fail to |
388 |
|
* insert an element only by throwing an exception. |
390 |
|
* <p>This method is equivalent to {@link #offerLast}. |
391 |
|
* |
392 |
|
* @param e the element to add |
393 |
< |
* @return <tt>true</tt> if the element was added to this deque, else |
394 |
< |
* <tt>false</tt> |
393 |
> |
* @return {@code true} if the element was added to this deque, else |
394 |
> |
* {@code false} |
395 |
|
* @throws ClassCastException if the class of the specified element |
396 |
|
* prevents it from being added to this deque |
397 |
|
* @throws NullPointerException if the specified element is null and this |
404 |
|
/** |
405 |
|
* Retrieves and removes the head of the queue represented by this deque |
406 |
|
* (in other words, the first element of this deque). |
407 |
< |
* This method differs from {@link #poll} only in that it throws an |
407 |
> |
* This method differs from {@link #poll poll} only in that it throws an |
408 |
|
* exception if this deque is empty. |
409 |
|
* |
410 |
|
* <p>This method is equivalent to {@link #removeFirst()}. |
417 |
|
/** |
418 |
|
* Retrieves and removes the head of the queue represented by this deque |
419 |
|
* (in other words, the first element of this deque), or returns |
420 |
< |
* <tt>null</tt> if this deque is empty. |
420 |
> |
* {@code null} if this deque is empty. |
421 |
|
* |
422 |
|
* <p>This method is equivalent to {@link #pollFirst()}. |
423 |
|
* |
424 |
< |
* @return the first element of this deque, or <tt>null</tt> if |
424 |
> |
* @return the first element of this deque, or {@code null} if |
425 |
|
* this deque is empty |
426 |
|
*/ |
427 |
|
E poll(); |
429 |
|
/** |
430 |
|
* Retrieves, but does not remove, the head of the queue represented by |
431 |
|
* this deque (in other words, the first element of this deque). |
432 |
< |
* This method differs from {@link #peek} only in that it throws an |
432 |
> |
* This method differs from {@link #peek peek} only in that it throws an |
433 |
|
* exception if this deque is empty. |
434 |
|
* |
435 |
|
* <p>This method is equivalent to {@link #getFirst()}. |
442 |
|
/** |
443 |
|
* Retrieves, but does not remove, the head of the queue represented by |
444 |
|
* this deque (in other words, the first element of this deque), or |
445 |
< |
* returns <tt>null</tt> if this deque is empty. |
445 |
> |
* returns {@code null} if this deque is empty. |
446 |
|
* |
447 |
|
* <p>This method is equivalent to {@link #peekFirst()}. |
448 |
|
* |
449 |
|
* @return the head of the queue represented by this deque, or |
450 |
< |
* <tt>null</tt> if this deque is empty |
450 |
> |
* {@code null} if this deque is empty |
451 |
|
*/ |
452 |
|
E peek(); |
453 |
|
|
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 |
461 |
< |
* <tt>true</tt> upon success and throwing an |
453 |
< |
* <tt>IllegalStateException</tt> if no space is currently available. |
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}. |
464 |
|
* |
492 |
|
/** |
493 |
|
* Removes the first occurrence of the specified element from this deque. |
494 |
|
* If the deque does not contain the element, it is unchanged. |
495 |
< |
* More formally, removes the first element <tt>e</tt> such that |
495 |
> |
* More formally, removes the first element {@code e} such that |
496 |
|
* <tt>(o==null ? e==null : o.equals(e))</tt> |
497 |
|
* (if such an element exists). |
498 |
< |
* Returns true if this deque contained the specified element (or |
499 |
< |
* equivalently, if this deque changed as a result of the call). |
498 |
> |
* Returns {@code true} if this deque contained the specified element |
499 |
> |
* (or equivalently, if this deque changed as a result of the call). |
500 |
|
* |
501 |
< |
* <p>This method is equivalent to {@link #removeFirstOccurrence}. |
501 |
> |
* <p>This method is equivalent to {@link #removeFirstOccurrence(Object)}. |
502 |
|
* |
503 |
|
* @param o element to be removed from this deque, if present |
504 |
< |
* @return <tt>true</tt> if an element was removed as a result of this call |
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 |
|
|
513 |
|
/** |
514 |
< |
* Returns <tt>true</tt> if this deque contains the specified element. |
515 |
< |
* More formally, returns <tt>true</tt> if and only if this deque contains |
516 |
< |
* at least one element <tt>e</tt> such that |
514 |
> |
* Returns {@code true} if this deque contains the specified element. |
515 |
> |
* More formally, returns {@code true} if and only if this deque contains |
516 |
> |
* at least one element {@code e} such that |
517 |
|
* <tt>(o==null ? e==null : o.equals(e))</tt>. |
518 |
|
* |
519 |
|
* @param o element whose presence in this deque is to be tested |
520 |
< |
* @return <tt>true</tt> 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) |
520 |
> |
* @return {@code true} if this deque contains the specified element |
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 |
|
|
540 |
|
* @return an iterator over the elements in this deque in proper sequence |
541 |
|
*/ |
542 |
|
Iterator<E> iterator(); |
543 |
+ |
|
544 |
+ |
/** |
545 |
+ |
* Returns an iterator over the elements in this deque in reverse |
546 |
+ |
* sequential order. The elements will be returned in order from |
547 |
+ |
* last (tail) to first (head). |
548 |
+ |
* |
549 |
+ |
* @return an iterator over the elements in this deque in reverse |
550 |
+ |
* sequence |
551 |
+ |
*/ |
552 |
+ |
Iterator<E> descendingIterator(); |
553 |
+ |
|
554 |
|
} |