ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/AbstractList.java
(Generate patch)

Comparing jsr166/src/main/java/util/AbstractList.java (file contents):
Revision 1.12 by jsr166, Mon Jun 26 00:46:50 2006 UTC vs.
Revision 1.13 by jsr166, Mon Jun 26 01:02:38 2006 UTC

# Line 8 | Line 8
8   package java.util;
9  
10   /**
11 < * This class provides a skeletal implementation of the {@code List}
11 > * This class provides a skeletal implementation of the {@link List}
12   * interface to minimize the effort required to implement this interface
13   * backed by a "random access" data store (such as an array).  For sequential
14 < * access data (such as a linked list), {@code AbstractSequentialList} should
14 > * access data (such as a linked list), {@link AbstractSequentialList} should
15   * be used in preference to this class.
16   *
17 < * <p>To implement an unmodifiable list, the programmer needs only to extend this
18 < * class and provide implementations for the {@code get(int index)} and
19 < * {@code size()} methods.
17 > * <p>To implement an unmodifiable list, the programmer needs only to extend
18 > * this class and provide implementations for the {@link #get(int)} and
19 > * {@link List#size() size()} methods.
20   *
21 < * <p>To implement a modifiable list, the programmer must additionally override
22 < * the {@code set(int index, Object element)} method (which otherwise throws
23 < * an {@code UnsupportedOperationException}.  If the list is variable-size
24 < * the programmer must additionally override the {@code add(int index, Object
25 < * element)} and {@code remove(int index)} methods.
21 > * <p>To implement a modifiable list, the programmer must additionally
22 > * override the {@link #set(int, Object) set(int, E)} method (which otherwise
23 > * throws an {@code UnsupportedOperationException}).  If the list is
24 > * variable-size the programmer must additionally override the
25 > * {@link #add(int, Object) add(int, E)} and {@link #remove(int)} methods.
26   *
27   * <p>The programmer should generally provide a void (no argument) and collection
28 < * constructor, as per the recommendation in the {@code Collection} interface
28 > * constructor, as per the recommendation in the {@link Collection} interface
29   * specification.
30   *
31   * <p>Unlike the other abstract collection implementations, the programmer does
32   * <i>not</i> have to provide an iterator implementation; the iterator and
33   * list iterator are implemented by this class, on top of the "random access"
34 < * methods: {@code get(int index)}, {@code set(int index, E element)},
35 < * {@code add(int index, E element)} and {@code remove(int index)}.
34 > * methods:
35 > * {@link #get(int)},
36 > * {@link #set(int, Object) set(int, E)},
37 > * {@link #add(int, Object) add(int, E)} and
38 > * {@link #remove(int)}.
39   *
40 < * <p>The documentation for each non-abstract methods in this class describes its
40 > * <p>The documentation for each non-abstract method in this class describes its
41   * implementation in detail.  Each of these methods may be overridden if the
42   * collection being implemented admits a more efficient implementation.
43   *
# Line 45 | Line 48 | package java.util;
48   * @author  Josh Bloch
49   * @author  Neal Gafter
50   * @version %I%, %G%
48 * @see Collection
49 * @see List
50 * @see AbstractSequentialList
51 * @see AbstractCollection
51   * @since 1.2
52   */
53  
# Line 74 | Line 73 | public abstract class AbstractList<E> ex
73       * <p>This implementation calls {@code add(size(), e)}.
74       *
75       * <p>Note that this implementation throws an
76 <     * {@code UnsupportedOperationException} unless {@code add(int, Object)}
77 <     * is overridden.
76 >     * {@code UnsupportedOperationException} unless
77 >     * {@link #add(int, Object) add(int, E)} is overridden.
78       *
79       * @param e element to be appended to this list
80       * @return {@code true} (as specified by {@link Collection#add})
# Line 221 | Line 220 | public abstract class AbstractList<E> ex
220      /**
221       * {@inheritDoc}
222       *
223 <     * <p>This implementation gets an iterator over the specified collection and
224 <     * iterates over it, inserting the elements obtained from the iterator
225 <     * into this list at the appropriate position, one at a time, using
226 <     * {@code add(int, Object)}.  Many implementations will override this
227 <     * method for efficiency.
223 >     * <p>This implementation gets an iterator over the specified collection
224 >     * and iterates over it, inserting the elements obtained from the
225 >     * iterator into this list at the appropriate position, one at a time,
226 >     * using {@code add(int, E)}.
227 >     * Many implementations will override this method for efficiency.
228       *
229       * <p>Note that this implementation throws an
230 <     * {@code UnsupportedOperationException} unless {@code add(int, Object)}
231 <     * is overridden.
230 >     * {@code UnsupportedOperationException} unless
231 >     * {@link #add(int, Object) add(int, E)} is overridden.
232       *
233       * @throws UnsupportedOperationException {@inheritDoc}
234       * @throws ClassCastException            {@inheritDoc}
# Line 252 | Line 251 | public abstract class AbstractList<E> ex
251  
252      /**
253       * Returns an iterator over the elements in this list in proper
254 <     * sequence. <p>
254 >     * sequence.
255       *
256 <     * This implementation returns a straightforward implementation of the
256 >     * <p>This implementation returns a straightforward implementation of the
257       * iterator interface, relying on the backing list's {@code size()},
258 <     * {@code get(int)}, and {@code remove(int)} methods.<p>
258 >     * {@code get(int)}, and {@code remove(int)} methods.
259       *
260 <     * Note that the iterator returned by this method will throw an
260 >     * <p>Note that the iterator returned by this method will throw an
261       * {@code UnsupportedOperationException} in response to its
262       * {@code remove} method unless the list's {@code remove(int)} method is
263 <     * overridden.<p>
263 >     * overridden.
264       *
265 <     * This implementation can be made to throw runtime exceptions in the face
266 <     * of concurrent modification, as described in the specification for the
267 <     * (protected) {@code modCount} field.
265 >     * <p>This implementation can be made to throw runtime exceptions in the
266 >     * face of concurrent modification, as described in the specification
267 >     * for the (protected) {@code modCount} field.
268       *
269       * @return an iterator over the elements in this list in proper sequence
270       *
# Line 293 | Line 292 | public abstract class AbstractList<E> ex
292       * {@code ListIterator} interface that extends the implementation of the
293       * {@code Iterator} interface returned by the {@code iterator()} method.
294       * The {@code ListIterator} implementation relies on the backing list's
295 <     * {@code get(int)}, {@code set(int, Object)}, {@code add(int, Object)}
295 >     * {@code get(int)}, {@code set(int, E)}, {@code add(int, Object)}
296       * and {@code remove(int)} methods.
297       *
298       * <p>Note that the list iterator returned by this implementation will
299       * throw an {@code UnsupportedOperationException} in response to its
300       * {@code remove}, {@code set} and {@code add} methods unless the
301 <     * list's {@code remove(int)}, {@code set(int, Object)}, and
302 <     * {@code add(int, Object)} methods are overridden.
301 >     * list's {@code remove(int)}, {@code set(int, E)}, and
302 >     * {@code add(int, E)} methods are overridden.
303       *
304       * <p>This implementation can be made to throw runtime exceptions in the
305       * face of concurrent modification, as described in the specification for
# Line 483 | Line 482 | public abstract class AbstractList<E> ex
482       * the two lists are <i>equal</i>.  (Two elements {@code e1} and
483       * {@code e2} are <i>equal</i> if {@code (e1==null ? e2==null :
484       * e1.equals(e2))}.)  In other words, two lists are defined to be
485 <     * equal if they contain the same elements in the same order.<p>
485 >     * equal if they contain the same elements in the same order.
486       *
487 <     * This implementation first checks if the specified object is this
487 >     * <p>This implementation first checks if the specified object is this
488       * list. If so, it returns {@code true}; if not, it checks if the
489       * specified object is a list. If not, it returns {@code false}; if so,
490       * it iterates over both lists, comparing corresponding pairs of elements.
# Line 515 | Line 514 | public abstract class AbstractList<E> ex
514      }
515  
516      /**
517 <     * Returns the hash code value for this list. <p>
517 >     * Returns the hash code value for this list.
518       *
519 <     * This implementation uses exactly the code that is used to define the
519 >     * <p>This implementation uses exactly the code that is used to define the
520       * list hash function in the documentation for the {@link List#hashCode}
521       * method.
522       *
# Line 539 | Line 538 | public abstract class AbstractList<E> ex
538       * Shifts any succeeding elements to the left (reduces their index).
539       * This call shortens the ArrayList by {@code (toIndex - fromIndex)}
540       * elements.  (If {@code toIndex==fromIndex}, this operation has no
541 <     * effect.)<p>
541 >     * effect.)
542       *
543 <     * This method is called by the {@code clear} operation on this list
543 >     * <p>This method is called by the {@code clear} operation on this list
544       * and its subLists.  Overriding this method to take advantage of
545       * the internals of the list implementation can <i>substantially</i>
546       * improve the performance of the {@code clear} operation on this list
547 <     * and its subLists.<p>
547 >     * and its subLists.
548       *
549 <     * This implementation gets a list iterator positioned before
549 >     * <p>This implementation gets a list iterator positioned before
550       * {@code fromIndex}, and repeatedly calls {@code ListIterator.next}
551       * followed by {@code ListIterator.remove} until the entire range has
552       * been removed.  <b>Note: if {@code ListIterator.remove} requires linear
# Line 568 | Line 567 | public abstract class AbstractList<E> ex
567       * The number of times this list has been <i>structurally modified</i>.
568       * Structural modifications are those that change the size of the
569       * list, or otherwise perturb it in such a fashion that iterations in
570 <     * progress may yield incorrect results.<p>
570 >     * progress may yield incorrect results.
571       *
572 <     * This field is used by the iterator and list iterator implementation
572 >     * <p>This field is used by the iterator and list iterator implementation
573       * returned by the {@code iterator} and {@code listIterator} methods.
574       * If the value of this field changes unexpectedly, the iterator (or list
575       * iterator) will throw a {@code ConcurrentModificationException} in
576       * response to the {@code next}, {@code remove}, {@code previous},
577       * {@code set} or {@code add} operations.  This provides
578       * <i>fail-fast</i> behavior, rather than non-deterministic behavior in
579 <     * the face of concurrent modification during iteration.<p>
579 >     * the face of concurrent modification during iteration.
580       *
581 <     * <b>Use of this field by subclasses is optional.</b> If a subclass
581 >     * <p><b>Use of this field by subclasses is optional.</b> If a subclass
582       * wishes to provide fail-fast iterators (and list iterators), then it
583       * merely has to increment this field in its {@code add(int, Object)} and
584       * {@code remove(int)} methods (and any other methods that it overrides

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines