24 |
|
* |
25 |
|
* <p>The iterators returned by this class's <tt>iterator</tt> method are |
26 |
|
* <i>fail-fast</i>: If the deque is modified at any time after the iterator |
27 |
< |
* is created, in any way except through the iterator's own remove method, the |
28 |
< |
* iterator will generally throw a {@link ConcurrentModificationException}. |
29 |
< |
* Thus, in the face of concurrent modification, the iterator fails quickly |
30 |
< |
* and cleanly, rather than risking arbitrary, non-deterministic behavior at |
31 |
< |
* an undetermined time in the future. |
27 |
> |
* is created, in any way except through the iterator's own <tt>remove</tt> |
28 |
> |
* method, the iterator will generally throw a {@link |
29 |
> |
* ConcurrentModificationException}. Thus, in the face of concurrent |
30 |
> |
* modification, the iterator fails quickly and cleanly, rather than risking |
31 |
> |
* arbitrary, non-deterministic behavior at an undetermined time in the |
32 |
> |
* future. |
33 |
|
* |
34 |
|
* <p>Note that the fail-fast behavior of an iterator cannot be guaranteed |
35 |
|
* as it is, generally speaking, impossible to make any hard guarantees in the |
130 |
|
} |
131 |
|
|
132 |
|
/** |
133 |
< |
* Copy the elements from our element array into the specified array, |
133 |
> |
* Copies the elements from our element array into the specified array, |
134 |
|
* in order (from first to last element in the deque). It is assumed |
135 |
|
* that the array is large enough to hold all elements in the deque. |
136 |
|
* |
199 |
|
} |
200 |
|
|
201 |
|
/** |
202 |
< |
* Inserts the specified element to the end of this deque. |
202 |
> |
* Inserts the specified element at the end of this deque. |
203 |
|
* This method is equivalent to {@link Collection#add} and |
204 |
|
* {@link #push}. |
205 |
|
* |
261 |
|
} |
262 |
|
|
263 |
|
/** |
264 |
< |
* Inserts the specified element to the end of this deque. |
264 |
> |
* Inserts the specified element at the end of this deque. |
265 |
|
* |
266 |
|
* @param e the element to insert |
267 |
|
* @return <tt>true</tt> (as per the spec for {@link Deque#offerLast}) |
409 |
|
// *** Queue methods *** |
410 |
|
|
411 |
|
/** |
412 |
< |
* Inserts the specified element to the end of this deque. |
412 |
> |
* Inserts the specified element at the end of this deque. |
413 |
|
* |
414 |
|
* <p>This method is equivalent to {@link #offerLast}. |
415 |
|
* |
422 |
|
} |
423 |
|
|
424 |
|
/** |
425 |
< |
* Inserts the specified element to the end of this deque. |
425 |
> |
* Inserts the specified element at the end of this deque. |
426 |
|
* |
427 |
|
* <p>This method is equivalent to {@link #addLast}. |
428 |
|
* |
521 |
|
} |
522 |
|
|
523 |
|
/** |
524 |
< |
* Remove the element at the specified position in the elements array, |
524 |
> |
* Removes the element at the specified position in the elements array, |
525 |
|
* adjusting head, tail, and size as necessary. This can result in |
526 |
|
* motion of elements backwards or forwards in the array. |
527 |
|
* |
559 |
|
} |
560 |
|
|
561 |
|
/** |
562 |
< |
* Returns <tt>true</tt> if this collection contains no elements.<p> |
562 |
> |
* Returns <tt>true</tt> if this deque contains no elements.<p> |
563 |
|
* |
564 |
< |
* @return <tt>true</tt> if this collection contains no elements. |
564 |
> |
* @return <tt>true</tt> if this deque contains no elements. |
565 |
|
*/ |
566 |
|
public boolean isEmpty() { |
567 |
|
return head == tail; |
660 |
|
|
661 |
|
/** |
662 |
|
* Removes all of the elements from this deque. |
663 |
+ |
* The deque will be empty after this call returns. |
664 |
|
*/ |
665 |
|
public void clear() { |
666 |
|
int h = head; |