< prev index next >

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

Print this page




  53  *
  54  * <p>The iterators returned by this class's {@code iterator} and
  55  * {@code listIterator} methods are <i>fail-fast</i>: if the list is
  56  * structurally modified at any time after the iterator is created, in
  57  * any way except through the Iterator's own {@code remove} or
  58  * {@code add} methods, the iterator will throw a {@link
  59  * ConcurrentModificationException}.  Thus, in the face of concurrent
  60  * modification, the iterator fails quickly and cleanly, rather than
  61  * risking arbitrary, non-deterministic behavior at an undetermined
  62  * time in the future.
  63  *
  64  * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
  65  * as it is, generally speaking, impossible to make any hard guarantees in the
  66  * presence of unsynchronized concurrent modification.  Fail-fast iterators
  67  * throw {@code ConcurrentModificationException} on a best-effort basis.
  68  * Therefore, it would be wrong to write a program that depended on this
  69  * exception for its correctness:   <i>the fail-fast behavior of iterators
  70  * should be used only to detect bugs.</i>
  71  *
  72  * <p>This class is a member of the
  73  * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  74  * Java Collections Framework</a>.
  75  *
  76  * @author  Josh Bloch
  77  * @see     List
  78  * @see     ArrayList
  79  * @since 1.2
  80  * @param <E> the type of elements held in this collection
  81  */
  82 
  83 public class LinkedList<E>
  84     extends AbstractSequentialList<E>
  85     implements List<E>, Deque<E>, Cloneable, java.io.Serializable
  86 {
  87     transient int size = 0;
  88 
  89     /**
  90      * Pointer to first node.
  91      */
  92     transient Node<E> first;
  93 




  53  *
  54  * <p>The iterators returned by this class's {@code iterator} and
  55  * {@code listIterator} methods are <i>fail-fast</i>: if the list is
  56  * structurally modified at any time after the iterator is created, in
  57  * any way except through the Iterator's own {@code remove} or
  58  * {@code add} methods, the iterator will throw a {@link
  59  * ConcurrentModificationException}.  Thus, in the face of concurrent
  60  * modification, the iterator fails quickly and cleanly, rather than
  61  * risking arbitrary, non-deterministic behavior at an undetermined
  62  * time in the future.
  63  *
  64  * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
  65  * as it is, generally speaking, impossible to make any hard guarantees in the
  66  * presence of unsynchronized concurrent modification.  Fail-fast iterators
  67  * throw {@code ConcurrentModificationException} on a best-effort basis.
  68  * Therefore, it would be wrong to write a program that depended on this
  69  * exception for its correctness:   <i>the fail-fast behavior of iterators
  70  * should be used only to detect bugs.</i>
  71  *
  72  * <p>This class is a member of the
  73  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
  74  * Java Collections Framework</a>.
  75  *
  76  * @author  Josh Bloch
  77  * @see     List
  78  * @see     ArrayList
  79  * @since 1.2
  80  * @param <E> the type of elements held in this collection
  81  */
  82 
  83 public class LinkedList<E>
  84     extends AbstractSequentialList<E>
  85     implements List<E>, Deque<E>, Cloneable, java.io.Serializable
  86 {
  87     transient int size = 0;
  88 
  89     /**
  90      * Pointer to first node.
  91      */
  92     transient Node<E> first;
  93 


< prev index next >