< prev index next >

src/java.base/share/classes/java/util/ArrayDeque.java

Print this page




  63  * the iterator is created, in any way except through the iterator's own
  64  * {@code remove} method, the iterator will generally throw a {@link
  65  * ConcurrentModificationException}.  Thus, in the face of concurrent
  66  * modification, the iterator fails quickly and cleanly, rather than risking
  67  * arbitrary, non-deterministic behavior at an undetermined time in the
  68  * future.
  69  *
  70  * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
  71  * as it is, generally speaking, impossible to make any hard guarantees in the
  72  * presence of unsynchronized concurrent modification.  Fail-fast iterators
  73  * throw {@code ConcurrentModificationException} on a best-effort basis.
  74  * Therefore, it would be wrong to write a program that depended on this
  75  * exception for its correctness: <i>the fail-fast behavior of iterators
  76  * should be used only to detect bugs.</i>
  77  *
  78  * <p>This class and its iterator implement all of the
  79  * <em>optional</em> methods of the {@link Collection} and {@link
  80  * Iterator} interfaces.
  81  *
  82  * <p>This class is a member of the
  83  * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  84  * Java Collections Framework</a>.
  85  *
  86  * @author  Josh Bloch and Doug Lea
  87  * @param <E> the type of elements held in this deque
  88  * @since   1.6
  89  */
  90 public class ArrayDeque<E> extends AbstractCollection<E>
  91                            implements Deque<E>, Cloneable, Serializable
  92 {
  93     /*
  94      * VMs excel at optimizing simple array loops where indices are
  95      * incrementing or decrementing over a valid slice, e.g.
  96      *
  97      * for (int i = start; i < end; i++) ... elements[i]
  98      *
  99      * Because in a circular array, elements are in general stored in
 100      * two disjoint such slices, we help the VM by writing unusual
 101      * nested loops for all traversals over the elements.  Having only
 102      * one hot inner loop body instead of two or three eases human
 103      * maintenance and encourages VM loop inlining into the caller.




  63  * the iterator is created, in any way except through the iterator's own
  64  * {@code remove} method, the iterator will generally throw a {@link
  65  * ConcurrentModificationException}.  Thus, in the face of concurrent
  66  * modification, the iterator fails quickly and cleanly, rather than risking
  67  * arbitrary, non-deterministic behavior at an undetermined time in the
  68  * future.
  69  *
  70  * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
  71  * as it is, generally speaking, impossible to make any hard guarantees in the
  72  * presence of unsynchronized concurrent modification.  Fail-fast iterators
  73  * throw {@code ConcurrentModificationException} on a best-effort basis.
  74  * Therefore, it would be wrong to write a program that depended on this
  75  * exception for its correctness: <i>the fail-fast behavior of iterators
  76  * should be used only to detect bugs.</i>
  77  *
  78  * <p>This class and its iterator implement all of the
  79  * <em>optional</em> methods of the {@link Collection} and {@link
  80  * Iterator} interfaces.
  81  *
  82  * <p>This class is a member of the
  83  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
  84  * Java Collections Framework</a>.
  85  *
  86  * @author  Josh Bloch and Doug Lea
  87  * @param <E> the type of elements held in this deque
  88  * @since   1.6
  89  */
  90 public class ArrayDeque<E> extends AbstractCollection<E>
  91                            implements Deque<E>, Cloneable, Serializable
  92 {
  93     /*
  94      * VMs excel at optimizing simple array loops where indices are
  95      * incrementing or decrementing over a valid slice, e.g.
  96      *
  97      * for (int i = start; i < end; i++) ... elements[i]
  98      *
  99      * Because in a circular array, elements are in general stored in
 100      * two disjoint such slices, we help the VM by writing unusual
 101      * nested loops for all traversals over the elements.  Having only
 102      * one hot inner loop body instead of two or three eases human
 103      * maintenance and encourages VM loop inlining into the caller.


< prev index next >