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; |
8 |
– |
import java.util.*; // for javadoc |
8 |
|
|
9 |
|
/** |
10 |
|
* A linear collection that supports element insertion and removal at |
153 |
|
* <tt>Object</tt>. |
154 |
|
* |
155 |
|
* <p>This interface is a member of the <a |
156 |
< |
* href="{@docRoot}/../guide/collections/index.html"> Java Collections |
156 |
> |
* href="{@docRoot}/../technotes/guides/collections/index.html"> Java Collections |
157 |
|
* Framework</a>. |
158 |
|
* |
159 |
|
* @author Doug Lea |
161 |
|
* @since 1.6 |
162 |
|
* @param <E> the type of elements held in this collection |
163 |
|
*/ |
165 |
– |
|
164 |
|
public interface Deque<E> extends Queue<E> { |
165 |
|
/** |
166 |
|
* Inserts the specified element at the front of this deque if it is |
238 |
|
|
239 |
|
/** |
240 |
|
* Retrieves and removes the first element of this deque. This method |
241 |
< |
* differs from {@link #pollFirst} only in that it throws an exception |
242 |
< |
* if this deque is empty. |
241 |
> |
* differs from {@link #pollFirst pollFirst} only in that it throws an |
242 |
> |
* exception if this deque is empty. |
243 |
|
* |
244 |
|
* @return the head of this deque |
245 |
|
* @throws NoSuchElementException if this deque is empty |
248 |
|
|
249 |
|
/** |
250 |
|
* Retrieves and removes the last element of this deque. This method |
251 |
< |
* differs from {@link #pollLast} only in that it throws an exception if |
252 |
< |
* this deque is empty. |
251 |
> |
* differs from {@link #pollLast pollLast} only in that it throws an |
252 |
> |
* exception if this deque is empty. |
253 |
|
* |
254 |
|
* @return the tail of this deque |
255 |
|
* @throws NoSuchElementException if this deque is empty |
274 |
|
|
275 |
|
/** |
276 |
|
* Retrieves, but does not remove, the first element of this deque. |
277 |
< |
* This method differs from {@link #peekFirst} only in that it throws an |
278 |
< |
* exception if this deque is empty. |
277 |
> |
* |
278 |
> |
* This method differs from {@link #peekFirst peekFirst} only in that it |
279 |
> |
* throws an exception if this deque is empty. |
280 |
|
* |
281 |
|
* @return the head of this deque |
282 |
|
* @throws NoSuchElementException if this deque is empty |
285 |
|
|
286 |
|
/** |
287 |
|
* Retrieves, but does not remove, the last element of this deque. |
288 |
< |
* This method differs from {@link #peekLast} only in that it throws an |
289 |
< |
* exception if this deque is empty. |
288 |
> |
* This method differs from {@link #peekLast peekLast} only in that it |
289 |
> |
* throws an exception if this deque is empty. |
290 |
|
* |
291 |
|
* @return the tail of this deque |
292 |
|
* @throws NoSuchElementException if this deque is empty |
359 |
|
* <p>This method is equivalent to {@link #addLast}. |
360 |
|
* |
361 |
|
* @param e the element to add |
362 |
< |
* @return <tt>true</tt> (as per the spec for {@link Collection#add}) |
362 |
> |
* @return <tt>true</tt> (as specified by {@link Collection#add}) |
363 |
|
* @throws IllegalStateException if the element cannot be added at this |
364 |
|
* time due to capacity restrictions |
365 |
|
* @throws ClassCastException if the class of the specified element |
397 |
|
/** |
398 |
|
* Retrieves and removes the head of the queue represented by this deque |
399 |
|
* (in other words, the first element of this deque). |
400 |
< |
* This method differs from {@link #poll} only in that it throws an |
400 |
> |
* This method differs from {@link #poll poll} only in that it throws an |
401 |
|
* exception if this deque is empty. |
402 |
|
* |
403 |
|
* <p>This method is equivalent to {@link #removeFirst()}. |
422 |
|
/** |
423 |
|
* Retrieves, but does not remove, the head of the queue represented by |
424 |
|
* this deque (in other words, the first element of this deque). |
425 |
< |
* This method differs from {@link #peek} only in that it throws an |
425 |
> |
* This method differs from {@link #peek peek} only in that it throws an |
426 |
|
* exception if this deque is empty. |
427 |
|
* |
428 |
|
* <p>This method is equivalent to {@link #getFirst()}. |
532 |
|
* @return an iterator over the elements in this deque in proper sequence |
533 |
|
*/ |
534 |
|
Iterator<E> iterator(); |
535 |
+ |
|
536 |
+ |
/** |
537 |
+ |
* Returns an iterator over the elements in this deque in reverse |
538 |
+ |
* sequential order. The elements will be returned in order from |
539 |
+ |
* last (tail) to first (head). |
540 |
+ |
* |
541 |
+ |
* @return an iterator over the elements in this deque in reverse |
542 |
+ |
* sequence |
543 |
+ |
*/ |
544 |
+ |
Iterator<E> descendingIterator(); |
545 |
+ |
|
546 |
|
} |