47 |
|
* {@link Stack} when used as a stack, and faster than {@link LinkedList} |
48 |
|
* when used as a queue. |
49 |
|
* |
50 |
< |
* <p>Most <tt>ArrayDeque</tt> operations run in amortized constant time. |
50 |
> |
* <p>Most {@code ArrayDeque} operations run in amortized constant time. |
51 |
|
* Exceptions include {@link #remove(Object) remove}, {@link |
52 |
|
* #removeFirstOccurrence removeFirstOccurrence}, {@link #removeLastOccurrence |
53 |
|
* removeLastOccurrence}, {@link #contains contains}, {@link #iterator |
54 |
|
* iterator.remove()}, and the bulk operations, all of which run in linear |
55 |
|
* time. |
56 |
|
* |
57 |
< |
* <p>The iterators returned by this class's <tt>iterator</tt> method are |
57 |
> |
* <p>The iterators returned by this class's {@code iterator} method are |
58 |
|
* <i>fail-fast</i>: If the deque is modified at any time after the iterator |
59 |
< |
* is created, in any way except through the iterator's own <tt>remove</tt> |
59 |
> |
* is created, in any way except through the iterator's own {@code remove} |
60 |
|
* method, the iterator will generally throw a {@link |
61 |
|
* ConcurrentModificationException}. Thus, in the face of concurrent |
62 |
|
* modification, the iterator fails quickly and cleanly, rather than risking |
66 |
|
* <p>Note that the fail-fast behavior of an iterator cannot be guaranteed |
67 |
|
* as it is, generally speaking, impossible to make any hard guarantees in the |
68 |
|
* presence of unsynchronized concurrent modification. Fail-fast iterators |
69 |
< |
* throw <tt>ConcurrentModificationException</tt> on a best-effort basis. |
69 |
> |
* throw {@code ConcurrentModificationException} on a best-effort basis. |
70 |
|
* Therefore, it would be wrong to write a program that depended on this |
71 |
|
* exception for its correctness: <i>the fail-fast behavior of iterators |
72 |
|
* should be used only to detect bugs.</i> |