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

Comparing jsr166/src/main/java/util/Vector.java (file contents):
Revision 1.12 by jsr166, Fri Apr 21 20:49:03 2006 UTC vs.
Revision 1.20 by jsr166, Sun Jan 7 07:38:27 2007 UTC

# Line 1 | Line 1
1   /*
2   * %W% %E%
3   *
4 < * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
4 > * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
5   * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6   */
7  
8   package java.util;
9  
10   /**
11 < * The <code>Vector</code> class implements a growable array of
11 > * The {@code Vector} class implements a growable array of
12   * objects. Like an array, it contains components that can be
13   * accessed using an integer index. However, the size of a
14 < * <code>Vector</code> can grow or shrink as needed to accommodate
15 < * adding and removing items after the <code>Vector</code> has been created.
14 > * {@code Vector} can grow or shrink as needed to accommodate
15 > * adding and removing items after the {@code Vector} has been created.
16   *
17   * <p>Each vector tries to optimize storage management by maintaining a
18 < * <code>capacity</code> and a <code>capacityIncrement</code>. The
19 < * <code>capacity</code> is always at least as large as the vector
18 > * {@code capacity} and a {@code capacityIncrement}. The
19 > * {@code capacity} is always at least as large as the vector
20   * size; it is usually larger because as components are added to the
21   * vector, the vector's storage increases in chunks the size of
22 < * <code>capacityIncrement</code>. An application can increase the
22 > * {@code capacityIncrement}. An application can increase the
23   * capacity of a vector before inserting a large number of
24   * components; this reduces the amount of incremental reallocation.
25   *
# Line 36 | Line 36 | package java.util;
36   * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
37   * as it is, generally speaking, impossible to make any hard guarantees in the
38   * presence of unsynchronized concurrent modification.  Fail-fast iterators
39 < * throw <tt>ConcurrentModificationException</tt> on a best-effort basis.
39 > * throw {@code ConcurrentModificationException} on a best-effort basis.
40   * Therefore, it would be wrong to write a program that depended on this
41   * exception for its correctness:  <i>the fail-fast behavior of iterators
42   * should be used only to detect bugs.</i>
43   *
44   * <p>As of the Java 2 platform v1.2, this class was retrofitted to
45   * implement the {@link List} interface, making it a member of the
46 < * <a href="{@docRoot}/../guide/collections/index.html"> Java
46 > * <a href="{@docRoot}/../technotes/guides/collections/index.html"> Java
47   * Collections Framework</a>.  Unlike the new collection
48   * implementations, {@code Vector} is synchronized.
49   *
# Line 63 | Line 63 | public class Vector<E>
63      /**
64       * The array buffer into which the components of the vector are
65       * stored. The capacity of the vector is the length of this array buffer,
66 <     * and is at least large enough to contain all the vector's elements.<p>
66 >     * and is at least large enough to contain all the vector's elements.
67       *
68 <     * Any array elements following the last element in the Vector are null.
68 >     * <p>Any array elements following the last element in the Vector are null.
69       *
70       * @serial
71       */
72      protected Object[] elementData;
73  
74      /**
75 <     * The number of valid components in this <tt>Vector</tt> object.
76 <     * Components <tt>elementData[0]</tt> through
77 <     * <tt>elementData[elementCount-1]</tt> are the actual items.
75 >     * The number of valid components in this {@code Vector} object.
76 >     * Components {@code elementData[0]} through
77 >     * {@code elementData[elementCount-1]} are the actual items.
78       *
79       * @serial
80       */
# Line 100 | Line 100 | public class Vector<E>
100       * @param   initialCapacity     the initial capacity of the vector
101       * @param   capacityIncrement   the amount by which the capacity is
102       *                              increased when the vector overflows
103 <     * @exception IllegalArgumentException if the specified initial capacity
104 <     *               is negative
103 >     * @throws IllegalArgumentException if the specified initial capacity
104 >     *         is negative
105       */
106      public Vector(int initialCapacity, int capacityIncrement) {
107          super();
# Line 117 | Line 117 | public class Vector<E>
117       * with its capacity increment equal to zero.
118       *
119       * @param   initialCapacity   the initial capacity of the vector
120 <     * @exception IllegalArgumentException if the specified initial capacity
121 <     *               is negative
120 >     * @throws IllegalArgumentException if the specified initial capacity
121 >     *         is negative
122       */
123      public Vector(int initialCapacity) {
124          this(initialCapacity, 0);
# Line 126 | Line 126 | public class Vector<E>
126  
127      /**
128       * Constructs an empty vector so that its internal data array
129 <     * has size <tt>10</tt> and its standard capacity increment is
129 >     * has size {@code 10} and its standard capacity increment is
130       * zero.
131       */
132      public Vector() {
# Line 153 | Line 153 | public class Vector<E>
153  
154      /**
155       * Copies the components of this vector into the specified array.
156 <     * The item at index <tt>k</tt> in this vector is copied into
157 <     * component <tt>k</tt> of <tt>anArray</tt>.
156 >     * The item at index {@code k} in this vector is copied into
157 >     * component {@code k} of {@code anArray}.
158       *
159       * @param  anArray the array into which the components get copied
160       * @throws NullPointerException if the given array is null
# Line 172 | Line 172 | public class Vector<E>
172       * Trims the capacity of this vector to be the vector's current
173       * size. If the capacity of this vector is larger than its current
174       * size, then the capacity is changed to equal the size by replacing
175 <     * its internal data array, kept in the field <tt>elementData</tt>,
175 >     * its internal data array, kept in the field {@code elementData},
176       * with a smaller one. An application can use this operation to
177       * minimize the storage of a vector.
178       */
# Line 190 | Line 190 | public class Vector<E>
190       * the minimum capacity argument.
191       *
192       * <p>If the current capacity of this vector is less than
193 <     * <tt>minCapacity</tt>, then its capacity is increased by replacing its
194 <     * internal data array, kept in the field <tt>elementData</tt>, with a
193 >     * {@code minCapacity}, then its capacity is increased by replacing its
194 >     * internal data array, kept in the field {@code elementData}, with a
195       * larger one.  The size of the new data array will be the old size plus
196 <     * <tt>capacityIncrement</tt>, unless the value of
197 <     * <tt>capacityIncrement</tt> is less than or equal to zero, in which case
196 >     * {@code capacityIncrement}, unless the value of
197 >     * {@code capacityIncrement} is less than or equal to zero, in which case
198       * the new capacity will be twice the old capacity; but if this new size
199 <     * is still smaller than <tt>minCapacity</tt>, then the new capacity will
200 <     * be <tt>minCapacity</tt>.
199 >     * is still smaller than {@code minCapacity}, then the new capacity will
200 >     * be {@code minCapacity}.
201       *
202       * @param minCapacity the desired minimum capacity
203       */
# Line 212 | Line 212 | public class Vector<E>
212       * method for ensuring capacity without incurring the cost of an
213       * extra synchronization.
214       *
215 <     * @see java.util.Vector#ensureCapacity(int)
215 >     * @see #ensureCapacity(int)
216       */
217      private void ensureCapacityHelper(int minCapacity) {
218          int oldCapacity = elementData.length;
# Line 229 | Line 229 | public class Vector<E>
229  
230      /**
231       * Sets the size of this vector. If the new size is greater than the
232 <     * current size, new <code>null</code> items are added to the end of
232 >     * current size, new {@code null} items are added to the end of
233       * the vector. If the new size is less than the current size, all
234 <     * components at index <code>newSize</code> and greater are discarded.
234 >     * components at index {@code newSize} and greater are discarded.
235       *
236 <     * @param   newSize   the new size of this vector
237 <     * @throws  ArrayIndexOutOfBoundsException if new size is negative
236 >     * @param  newSize   the new size of this vector
237 >     * @throws ArrayIndexOutOfBoundsException if the new size is negative
238       */
239      public synchronized void setSize(int newSize) {
240          modCount++;
# Line 252 | Line 252 | public class Vector<E>
252       * Returns the current capacity of this vector.
253       *
254       * @return  the current capacity (the length of its internal
255 <     *          data array, kept in the field <tt>elementData</tt>
255 >     *          data array, kept in the field {@code elementData}
256       *          of this vector)
257       */
258      public synchronized int capacity() {
# Line 271 | Line 271 | public class Vector<E>
271      /**
272       * Tests if this vector has no components.
273       *
274 <     * @return  <code>true</code> if and only if this vector has
274 >     * @return  {@code true} if and only if this vector has
275       *          no components, that is, its size is zero;
276 <     *          <code>false</code> otherwise.
276 >     *          {@code false} otherwise.
277       */
278      public synchronized boolean isEmpty() {
279          return elementCount == 0;
# Line 281 | Line 281 | public class Vector<E>
281  
282      /**
283       * Returns an enumeration of the components of this vector. The
284 <     * returned <tt>Enumeration</tt> object will generate all items in
285 <     * this vector. The first item generated is the item at index <tt>0</tt>,
286 <     * then the item at index <tt>1</tt>, and so on.
284 >     * returned {@code Enumeration} object will generate all items in
285 >     * this vector. The first item generated is the item at index {@code 0},
286 >     * then the item at index {@code 1}, and so on.
287       *
288       * @return  an enumeration of the components of this vector
289     * @see     Enumeration
289       * @see     Iterator
290       */
291      public Enumeration<E> elements() {
# Line 309 | Line 308 | public class Vector<E>
308      }
309  
310      /**
311 <     * Returns <tt>true</tt> if this vector contains the specified element.
312 <     * More formally, returns <tt>true</tt> if and only if this vector
313 <     * contains at least one element <tt>e</tt> such that
311 >     * Returns {@code true} if this vector contains the specified element.
312 >     * More formally, returns {@code true} if and only if this vector
313 >     * contains at least one element {@code e} such that
314       * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>.
315       *
316       * @param o element whose presence in this vector is to be tested
317 <     * @return <tt>true</tt> if this vector contains the specified element
317 >     * @return {@code true} if this vector contains the specified element
318       */
319      public boolean contains(Object o) {
320          return indexOf(o, 0) >= 0;
# Line 324 | Line 323 | public class Vector<E>
323      /**
324       * Returns the index of the first occurrence of the specified element
325       * in this vector, or -1 if this vector does not contain the element.
326 <     * More formally, returns the lowest index <tt>i</tt> such that
326 >     * More formally, returns the lowest index {@code i} such that
327       * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
328       * or -1 if there is no such index.
329       *
# Line 338 | Line 337 | public class Vector<E>
337  
338      /**
339       * Returns the index of the first occurrence of the specified element in
340 <     * this vector, searching forwards from <tt>index</tt>, or returns -1 if
340 >     * this vector, searching forwards from {@code index}, or returns -1 if
341       * the element is not found.
342 <     * More formally, returns the lowest index <tt>i</tt> such that
342 >     * More formally, returns the lowest index {@code i} such that
343       * <tt>(i&nbsp;&gt;=&nbsp;index&nbsp;&amp;&amp;&nbsp;(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i))))</tt>,
344       * or -1 if there is no such index.
345       *
346       * @param o element to search for
347       * @param index index to start searching from
348       * @return the index of the first occurrence of the element in
349 <     *         this vector at position <tt>index</tt> or later in the vector;
350 <     *         <tt>-1</tt> if the element is not found.
349 >     *         this vector at position {@code index} or later in the vector;
350 >     *         {@code -1} if the element is not found.
351       * @throws IndexOutOfBoundsException if the specified index is negative
352       * @see     Object#equals(Object)
353       */
# Line 368 | Line 367 | public class Vector<E>
367      /**
368       * Returns the index of the last occurrence of the specified element
369       * in this vector, or -1 if this vector does not contain the element.
370 <     * More formally, returns the highest index <tt>i</tt> such that
370 >     * More formally, returns the highest index {@code i} such that
371       * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
372       * or -1 if there is no such index.
373       *
# Line 382 | Line 381 | public class Vector<E>
381  
382      /**
383       * Returns the index of the last occurrence of the specified element in
384 <     * this vector, searching backwards from <tt>index</tt>, or returns -1 if
384 >     * this vector, searching backwards from {@code index}, or returns -1 if
385       * the element is not found.
386 <     * More formally, returns the highest index <tt>i</tt> such that
386 >     * More formally, returns the highest index {@code i} such that
387       * <tt>(i&nbsp;&lt;=&nbsp;index&nbsp;&amp;&amp;&nbsp;(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i))))</tt>,
388       * or -1 if there is no such index.
389       *
390       * @param o element to search for
391       * @param index index to start searching backwards from
392       * @return the index of the last occurrence of the element at position
393 <     *         less than or equal to <tt>index</tt> in this vector;
393 >     *         less than or equal to {@code index} in this vector;
394       *         -1 if the element is not found.
395       * @throws IndexOutOfBoundsException if the specified index is greater
396       *         than or equal to the current size of this vector
# Line 413 | Line 412 | public class Vector<E>
412      }
413  
414      /**
415 <     * Returns the component at the specified index.<p>
415 >     * Returns the component at the specified index.
416       *
417 <     * This method is identical in functionality to the get method
418 <     * (which is part of the List interface).
417 >     * <p>This method is identical in functionality to the {@link #get(int)}
418 >     * method (which is part of the {@link List} interface).
419       *
420       * @param      index   an index into this vector
421       * @return     the component at the specified index
422 <     * @exception  ArrayIndexOutOfBoundsException  if the <tt>index</tt>
423 <     *             is negative or not less than the current size of this
425 <     *             <tt>Vector</tt> object.
426 <     * @see        #get(int)
427 <     * @see        List
422 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
423 >     *         ({@code index < 0 || index >= size()})
424       */
425      public synchronized E elementAt(int index) {
426          if (index >= elementCount) {
# Line 435 | Line 431 | public class Vector<E>
431      }
432  
433      /**
434 <     * Returns the first component (the item at index <tt>0</tt>) of
434 >     * Returns the first component (the item at index {@code 0}) of
435       * this vector.
436       *
437       * @return     the first component of this vector
438 <     * @exception  NoSuchElementException  if this vector has no components
438 >     * @throws NoSuchElementException if this vector has no components
439       */
440      public synchronized E firstElement() {
441          if (elementCount == 0) {
# Line 453 | Line 449 | public class Vector<E>
449       *
450       * @return  the last component of the vector, i.e., the component at index
451       *          <code>size()&nbsp;-&nbsp;1</code>.
452 <     * @exception  NoSuchElementException  if this vector is empty
452 >     * @throws NoSuchElementException if this vector is empty
453       */
454      public synchronized E lastElement() {
455          if (elementCount == 0) {
# Line 463 | Line 459 | public class Vector<E>
459      }
460  
461      /**
462 <     * Sets the component at the specified <code>index</code> of this
462 >     * Sets the component at the specified {@code index} of this
463       * vector to be the specified object. The previous component at that
464 <     * position is discarded.<p>
464 >     * position is discarded.
465       *
466 <     * The index must be a value greater than or equal to <code>0</code>
467 <     * and less than the current size of the vector. <p>
466 >     * <p>The index must be a value greater than or equal to {@code 0}
467 >     * and less than the current size of the vector.
468       *
469 <     * This method is identical in functionality to the set method
470 <     * (which is part of the List interface). Note that the set method reverses
471 <     * the order of the parameters, to more closely match array usage.  Note
472 <     * also that the set method returns the old value that was stored at the
473 <     * specified position.
469 >     * <p>This method is identical in functionality to the
470 >     * {@link #set(int, Object) set(int, E)}
471 >     * method (which is part of the {@link List} interface). Note that the
472 >     * {@code set} method reverses the order of the parameters, to more closely
473 >     * match array usage.  Note also that the {@code set} method returns the
474 >     * old value that was stored at the specified position.
475       *
476       * @param      obj     what the component is to be set to
477       * @param      index   the specified index
478 <     * @exception  ArrayIndexOutOfBoundsException  if the index was invalid
479 <     * @see        #size()
483 <     * @see        List
484 <     * @see        #set(int, java.lang.Object)
478 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
479 >     *         ({@code index < 0 || index >= size()})
480       */
481      public synchronized void setElementAt(E obj, int index) {
482          if (index >= elementCount) {
# Line 494 | Line 489 | public class Vector<E>
489      /**
490       * Deletes the component at the specified index. Each component in
491       * this vector with an index greater or equal to the specified
492 <     * <code>index</code> is shifted downward to have an index one
492 >     * {@code index} is shifted downward to have an index one
493       * smaller than the value it had previously. The size of this vector
494 <     * is decreased by <tt>1</tt>.<p>
494 >     * is decreased by {@code 1}.
495       *
496 <     * The index must be a value greater than or equal to <code>0</code>
497 <     * and less than the current size of the vector. <p>
496 >     * <p>The index must be a value greater than or equal to {@code 0}
497 >     * and less than the current size of the vector.
498       *
499 <     * This method is identical in functionality to the remove method
500 <     * (which is part of the List interface).  Note that the remove method
501 <     * returns the old value that was stored at the specified position.
499 >     * <p>This method is identical in functionality to the {@link #remove(int)}
500 >     * method (which is part of the {@link List} interface).  Note that the
501 >     * {@code remove} method returns the old value that was stored at the
502 >     * specified position.
503       *
504       * @param      index   the index of the object to remove
505 <     * @exception  ArrayIndexOutOfBoundsException  if the index was invalid
506 <     * @see        #size()
511 <     * @see        #remove(int)
512 <     * @see        List
505 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
506 >     *         ({@code index < 0 || index >= size()})
507       */
508      public synchronized void removeElementAt(int index) {
509          modCount++;
# Line 530 | Line 524 | public class Vector<E>
524  
525      /**
526       * Inserts the specified object as a component in this vector at the
527 <     * specified <code>index</code>. Each component in this vector with
528 <     * an index greater or equal to the specified <code>index</code> is
527 >     * specified {@code index}. Each component in this vector with
528 >     * an index greater or equal to the specified {@code index} is
529       * shifted upward to have an index one greater than the value it had
530 <     * previously. <p>
530 >     * previously.
531       *
532 <     * The index must be a value greater than or equal to <code>0</code>
532 >     * <p>The index must be a value greater than or equal to {@code 0}
533       * and less than or equal to the current size of the vector. (If the
534       * index is equal to the current size of the vector, the new element
535 <     * is appended to the Vector.)<p>
535 >     * is appended to the Vector.)
536       *
537 <     * This method is identical in functionality to the add(Object, int) method
538 <     * (which is part of the List interface). Note that the add method reverses
539 <     * the order of the parameters, to more closely match array usage.
537 >     * <p>This method is identical in functionality to the
538 >     * {@link #add(int, Object) add(int, E)}
539 >     * method (which is part of the {@link List} interface).  Note that the
540 >     * {@code add} method reverses the order of the parameters, to more closely
541 >     * match array usage.
542       *
543       * @param      obj     the component to insert
544       * @param      index   where to insert the new component
545 <     * @exception  ArrayIndexOutOfBoundsException  if the index was invalid
546 <     * @see        #size()
551 <     * @see        #add(int, Object)
552 <     * @see        List
545 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
546 >     *         ({@code index < 0 || index > size()})
547       */
548      public synchronized void insertElementAt(E obj, int index) {
549          modCount++;
# Line 566 | Line 560 | public class Vector<E>
560      /**
561       * Adds the specified component to the end of this vector,
562       * increasing its size by one. The capacity of this vector is
563 <     * increased if its size becomes greater than its capacity. <p>
563 >     * increased if its size becomes greater than its capacity.
564       *
565 <     * This method is identical in functionality to the add(Object) method
566 <     * (which is part of the List interface).
565 >     * <p>This method is identical in functionality to the
566 >     * {@link #add(Object) add(E)}
567 >     * method (which is part of the {@link List} interface).
568       *
569       * @param   obj   the component to be added
575     * @see        #add(Object)
576     * @see        List
570       */
571      public synchronized void addElement(E obj) {
572          modCount++;
# Line 586 | Line 579 | public class Vector<E>
579       * from this vector. If the object is found in this vector, each
580       * component in the vector with an index greater or equal to the
581       * object's index is shifted downward to have an index one smaller
582 <     * than the value it had previously.<p>
582 >     * than the value it had previously.
583       *
584 <     * This method is identical in functionality to the remove(Object)
585 <     * method (which is part of the List interface).
584 >     * <p>This method is identical in functionality to the
585 >     * {@link #remove(Object)} method (which is part of the
586 >     * {@link List} interface).
587       *
588       * @param   obj   the component to be removed
589 <     * @return  <code>true</code> if the argument was a component of this
590 <     *          vector; <code>false</code> otherwise.
597 <     * @see     List#remove(Object)
598 <     * @see     List
589 >     * @return  {@code true} if the argument was a component of this
590 >     *          vector; {@code false} otherwise.
591       */
592      public synchronized boolean removeElement(Object obj) {
593          modCount++;
# Line 608 | Line 600 | public class Vector<E>
600      }
601  
602      /**
603 <     * Removes all components from this vector and sets its size to zero.<p>
612 <     *
613 <     * This method is identical in functionality to the clear method
614 <     * (which is part of the List interface).
603 >     * Removes all components from this vector and sets its size to zero.
604       *
605 <     * @see     #clear
606 <     * @see     List
605 >     * <p>This method is identical in functionality to the {@link #clear}
606 >     * method (which is part of the {@link List} interface).
607       */
608      public synchronized void removeAllElements() {
609          modCount++;
# Line 628 | Line 617 | public class Vector<E>
617      /**
618       * Returns a clone of this vector. The copy will contain a
619       * reference to a clone of the internal data array, not a reference
620 <     * to the original internal data array of this <tt>Vector</tt> object.
620 >     * to the original internal data array of this {@code Vector} object.
621       *
622       * @return  a clone of this vector
623       */
# Line 659 | Line 648 | public class Vector<E>
648       * correct order; the runtime type of the returned array is that of the
649       * specified array.  If the Vector fits in the specified array, it is
650       * returned therein.  Otherwise, a new array is allocated with the runtime
651 <     * type of the specified array and the size of this Vector.<p>
651 >     * type of the specified array and the size of this Vector.
652       *
653 <     * If the Vector fits in the specified array with room to spare
653 >     * <p>If the Vector fits in the specified array with room to spare
654       * (i.e., the array has more elements than the Vector),
655       * the element in the array immediately following the end of the
656       * Vector is set to null.  (This is useful in determining the length
# Line 672 | Line 661 | public class Vector<E>
661       *          be stored, if it is big enough; otherwise, a new array of the
662       *          same runtime type is allocated for this purpose.
663       * @return an array containing the elements of the Vector
664 <     * @exception ArrayStoreException the runtime type of a is not a supertype
664 >     * @throws ArrayStoreException if the runtime type of a is not a supertype
665       * of the runtime type of every element in this Vector
666       * @throws NullPointerException if the given array is null
667       * @since 1.2
# Line 696 | Line 685 | public class Vector<E>
685       *
686       * @param index index of the element to return
687       * @return object at the specified index
688 <     * @exception ArrayIndexOutOfBoundsException index is out of range (index
689 <     *            &lt; 0 || index &gt;= size())
688 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
689 >     *            ({@code index < 0 || index >= size()})
690       * @since 1.2
691       */
692      public synchronized E get(int index) {
# Line 714 | Line 703 | public class Vector<E>
703       * @param index index of the element to replace
704       * @param element element to be stored at the specified position
705       * @return the element previously at the specified position
706 <     * @exception ArrayIndexOutOfBoundsException index out of range
707 <     *            (index &lt; 0 || index &gt;= size())
706 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
707 >     *         ({@code index < 0 || index >= size()})
708       * @since 1.2
709       */
710      public synchronized E set(int index, E element) {
# Line 731 | Line 720 | public class Vector<E>
720       * Appends the specified element to the end of this Vector.
721       *
722       * @param e element to be appended to this Vector
723 <     * @return <tt>true</tt> (as specified by {@link Collection#add})
723 >     * @return {@code true} (as specified by {@link Collection#add})
724       * @since 1.2
725       */
726      public synchronized boolean add(E e) {
# Line 745 | Line 734 | public class Vector<E>
734       * Removes the first occurrence of the specified element in this Vector
735       * If the Vector does not contain the element, it is unchanged.  More
736       * formally, removes the element with the lowest index i such that
737 <     * <code>(o==null ? get(i)==null : o.equals(get(i)))</code> (if such
737 >     * {@code (o==null ? get(i)==null : o.equals(get(i)))} (if such
738       * an element exists).
739       *
740       * @param o element to be removed from this Vector, if present
# Line 763 | Line 752 | public class Vector<E>
752       *
753       * @param index index at which the specified element is to be inserted
754       * @param element element to be inserted
755 <     * @exception ArrayIndexOutOfBoundsException index is out of range
756 <     *            (index &lt; 0 || index &gt; size())
755 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
756 >     *         ({@code index < 0 || index > size()})
757       * @since 1.2
758       */
759      public void add(int index, E element) {
# Line 776 | Line 765 | public class Vector<E>
765       * Shifts any subsequent elements to the left (subtracts one from their
766       * indices).  Returns the element that was removed from the Vector.
767       *
768 <     * @exception ArrayIndexOutOfBoundsException index out of range (index
769 <     *            &lt; 0 || index &gt;= size())
768 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
769 >     *         ({@code index < 0 || index >= size()})
770       * @param index the index of the element to be removed
771       * @return element that was removed
772       * @since 1.2
# Line 832 | Line 821 | public class Vector<E>
821       * specified Collection is this Vector, and this Vector is nonempty.)
822       *
823       * @param c elements to be inserted into this Vector
824 <     * @return <tt>true</tt> if this Vector changed as a result of the call
824 >     * @return {@code true} if this Vector changed as a result of the call
825       * @throws NullPointerException if the specified collection is null
826       * @since 1.2
827       */
# Line 895 | Line 884 | public class Vector<E>
884       * @param index index at which to insert the first element from the
885       *              specified collection
886       * @param c elements to be inserted into this Vector
887 <     * @return <tt>true</tt> if this Vector changed as a result of the call
888 <     * @exception ArrayIndexOutOfBoundsException index out of range (index
889 <     *            &lt; 0 || index &gt; size())
887 >     * @return {@code true} if this Vector changed as a result of the call
888 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
889 >     *         ({@code index < 0 || index > size()})
890       * @throws NullPointerException if the specified collection is null
891       * @since 1.2
892       */
# Line 924 | Line 913 | public class Vector<E>
913       * Compares the specified Object with this Vector for equality.  Returns
914       * true if and only if the specified Object is also a List, both Lists
915       * have the same size, and all corresponding pairs of elements in the two
916 <     * Lists are <em>equal</em>.  (Two elements <code>e1</code> and
917 <     * <code>e2</code> are <em>equal</em> if <code>(e1==null ? e2==null :
918 <     * e1.equals(e2))</code>.)  In other words, two Lists are defined to be
916 >     * Lists are <em>equal</em>.  (Two elements {@code e1} and
917 >     * {@code e2} are <em>equal</em> if {@code (e1==null ? e2==null :
918 >     * e1.equals(e2))}.)  In other words, two Lists are defined to be
919       * equal if they contain the same elements in the same order.
920       *
921       * @param o the Object to be compared for equality with this Vector
# Line 974 | Line 963 | public class Vector<E>
963      }
964  
965      /**
966 <     * Save the state of the <tt>Vector</tt> instance to a stream (that
966 >     * Save the state of the {@code Vector} instance to a stream (that
967       * is, serialize it).  This method is present merely for synchronization.
968       * It just calls the default writeObject method.
969       */
# Line 1044 | Line 1033 | public class Vector<E>
1033  
1034      /**
1035       * Streamlined specialization of AbstractList version of iterator.
1036 <     * Locally perfroms bounds checks, but relies on outer Vector
1036 >     * Locally performs bounds checks, but relies on outer Vector
1037       * to access elements under synchronization.
1038       */
1039      private final class VectorIterator implements ListIterator<E> {
# Line 1149 | Line 1138 | public class Vector<E>
1138       * equal, the returned List is empty.)  The returned List is backed by this
1139       * List, so changes in the returned List are reflected in this List, and
1140       * vice-versa.  The returned List supports all of the optional List
1141 <     * operations supported by this List.<p>
1141 >     * operations supported by this List.
1142       *
1143 <     * This method eliminates the need for explicit range operations (of
1143 >     * <p>This method eliminates the need for explicit range operations (of
1144       * the sort that commonly exist for arrays).   Any operation that expects
1145       * a List can be used as a range operation by operating on a subList view
1146       * instead of a whole List.  For example, the following idiom
# Line 1161 | Line 1150 | public class Vector<E>
1150       * </pre>
1151       * Similar idioms may be constructed for indexOf and lastIndexOf,
1152       * and all of the algorithms in the Collections class can be applied to
1153 <     * a subList.<p>
1153 >     * a subList.
1154       *
1155 <     * The semantics of the List returned by this method become undefined if
1155 >     * <p>The semantics of the List returned by this method become undefined if
1156       * the backing list (i.e., this List) is <i>structurally modified</i> in
1157       * any way other than via the returned List.  (Structural modifications are
1158       * those that change the size of the List, or otherwise perturb it in such
# Line 1172 | Line 1161 | public class Vector<E>
1161       * @param fromIndex low endpoint (inclusive) of the subList
1162       * @param toIndex high endpoint (exclusive) of the subList
1163       * @return a view of the specified range within this List
1164 <     * @throws IndexOutOfBoundsException endpoint index value out of range
1165 <     *         <code>(fromIndex &lt; 0 || toIndex &gt; size)</code>
1166 <     * @throws IllegalArgumentException endpoint indices out of order
1167 <     *         <code>(fromIndex &gt; toIndex)</code>
1164 >     * @throws IndexOutOfBoundsException if an endpoint index value is out of range
1165 >     *         {@code (fromIndex < 0 || toIndex > size)}
1166 >     * @throws IllegalArgumentException if the endpoint indices are out of order
1167 >     *         {@code (fromIndex > toIndex)}
1168       */
1169      public synchronized List<E> subList(int fromIndex, int toIndex) {
1170          return new VectorSubList(this, this, fromIndex, fromIndex, toIndex);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines