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.15 by jsr166, Sun Jun 25 19:58:14 2006 UTC vs.
Revision 1.21 by jsr166, Sun May 20 07:54:01 2007 UTC

# Line 1 | Line 1
1   /*
2 < * %W% %E%
2 > * Copyright 1994-2006 Sun Microsystems, Inc.  All Rights Reserved.
3 > * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4   *
5 < * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
6 < * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
5 > * This code is free software; you can redistribute it and/or modify it
6 > * under the terms of the GNU General Public License version 2 only, as
7 > * published by the Free Software Foundation.  Sun designates this
8 > * particular file as subject to the "Classpath" exception as provided
9 > * by Sun in the LICENSE file that accompanied this code.
10 > *
11 > * This code is distributed in the hope that it will be useful, but WITHOUT
12 > * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 > * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 > * version 2 for more details (a copy is included in the LICENSE file that
15 > * accompanied this code).
16 > *
17 > * You should have received a copy of the GNU General Public License version
18 > * 2 along with this work; if not, write to the Free Software Foundation,
19 > * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 > *
21 > * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 > * CA 95054 USA or visit www.sun.com if you need additional information or
23 > * have any questions.
24   */
25  
26   package java.util;
# Line 233 | Line 251 | public class Vector<E>
251       * the vector. If the new size is less than the current size, all
252       * components at index {@code newSize} and greater are discarded.
253       *
254 <     * @param   newSize   the new size of this vector
255 <     * @throws  ArrayIndexOutOfBoundsException if new size is negative
254 >     * @param  newSize   the new size of this vector
255 >     * @throws ArrayIndexOutOfBoundsException if the new size is negative
256       */
257      public synchronized void setSize(int newSize) {
258          modCount++;
# Line 461 | Line 479 | public class Vector<E>
479      /**
480       * Sets the component at the specified {@code index} of this
481       * vector to be the specified object. The previous component at that
482 <     * position is discarded.<p>
482 >     * position is discarded.
483       *
484 <     * The index must be a value greater than or equal to {@code 0}
485 <     * and less than the current size of the vector. <p>
484 >     * <p>The index must be a value greater than or equal to {@code 0}
485 >     * and less than the current size of the vector.
486       *
487 <     * This method is identical in functionality to the set method
488 <     * (which is part of the List interface). Note that the set method reverses
489 <     * the order of the parameters, to more closely match array usage.  Note
490 <     * also that the set method returns the old value that was stored at the
491 <     * specified position.
487 >     * <p>This method is identical in functionality to the
488 >     * {@link #set(int, Object) set(int, E)}
489 >     * method (which is part of the {@link List} interface). Note that the
490 >     * {@code set} method reverses the order of the parameters, to more closely
491 >     * match array usage.  Note also that the {@code set} method returns the
492 >     * old value that was stored at the specified position.
493       *
494       * @param      obj     what the component is to be set to
495       * @param      index   the specified index
496 <     * @throws  ArrayIndexOutOfBoundsException  if the index was invalid
497 <     * @see        #size()
479 <     * @see        List
480 <     * @see        #set(int, java.lang.Object)
496 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
497 >     *         ({@code index < 0 || index >= size()})
498       */
499      public synchronized void setElementAt(E obj, int index) {
500          if (index >= elementCount) {
# Line 497 | Line 514 | public class Vector<E>
514       * <p>The index must be a value greater than or equal to {@code 0}
515       * and less than the current size of the vector.
516       *
517 <     * <p>This method is identical in functionality to the remove method
518 <     * (which is part of the List interface).  Note that the remove method
519 <     * returns the old value that was stored at the specified position.
517 >     * <p>This method is identical in functionality to the {@link #remove(int)}
518 >     * method (which is part of the {@link List} interface).  Note that the
519 >     * {@code remove} method returns the old value that was stored at the
520 >     * specified position.
521       *
522       * @param      index   the index of the object to remove
523 <     * @exception  ArrayIndexOutOfBoundsException  if the index was invalid
524 <     * @see        #size()
507 <     * @see        #remove(int)
508 <     * @see        List
523 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
524 >     *         ({@code index < 0 || index >= size()})
525       */
526      public synchronized void removeElementAt(int index) {
527          modCount++;
# Line 536 | Line 552 | public class Vector<E>
552       * index is equal to the current size of the vector, the new element
553       * is appended to the Vector.)
554       *
555 <     * <p>This method is identical in functionality to the add(Object, int) method
556 <     * (which is part of the List interface). Note that the add method reverses
557 <     * the order of the parameters, to more closely match array usage.
555 >     * <p>This method is identical in functionality to the
556 >     * {@link #add(int, Object) add(int, E)}
557 >     * method (which is part of the {@link List} interface).  Note that the
558 >     * {@code add} method reverses the order of the parameters, to more closely
559 >     * match array usage.
560       *
561       * @param      obj     the component to insert
562       * @param      index   where to insert the new component
563 <     * @exception  ArrayIndexOutOfBoundsException  if the index was invalid
564 <     * @see        #size()
547 <     * @see        #add(int, Object)
548 <     * @see        List
563 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
564 >     *         ({@code index < 0 || index > size()})
565       */
566      public synchronized void insertElementAt(E obj, int index) {
567          modCount++;
# Line 562 | Line 578 | public class Vector<E>
578      /**
579       * Adds the specified component to the end of this vector,
580       * increasing its size by one. The capacity of this vector is
581 <     * increased if its size becomes greater than its capacity. <p>
581 >     * increased if its size becomes greater than its capacity.
582       *
583 <     * This method is identical in functionality to the add(Object) method
584 <     * (which is part of the List interface).
583 >     * <p>This method is identical in functionality to the
584 >     * {@link #add(Object) add(E)}
585 >     * method (which is part of the {@link List} interface).
586       *
587       * @param   obj   the component to be added
571     * @see        #add(Object)
572     * @see        List
588       */
589      public synchronized void addElement(E obj) {
590          modCount++;
# Line 582 | Line 597 | public class Vector<E>
597       * from this vector. If the object is found in this vector, each
598       * component in the vector with an index greater or equal to the
599       * object's index is shifted downward to have an index one smaller
600 <     * than the value it had previously.<p>
600 >     * than the value it had previously.
601       *
602 <     * This method is identical in functionality to the remove(Object)
603 <     * method (which is part of the List interface).
602 >     * <p>This method is identical in functionality to the
603 >     * {@link #remove(Object)} method (which is part of the
604 >     * {@link List} interface).
605       *
606       * @param   obj   the component to be removed
607       * @return  {@code true} if the argument was a component of this
608       *          vector; {@code false} otherwise.
593     * @see     List#remove(Object)
594     * @see     List
609       */
610      public synchronized boolean removeElement(Object obj) {
611          modCount++;
# Line 604 | Line 618 | public class Vector<E>
618      }
619  
620      /**
621 <     * Removes all components from this vector and sets its size to zero.<p>
608 <     *
609 <     * This method is identical in functionality to the clear method
610 <     * (which is part of the List interface).
621 >     * Removes all components from this vector and sets its size to zero.
622       *
623 <     * @see     #clear
624 <     * @see     List
623 >     * <p>This method is identical in functionality to the {@link #clear}
624 >     * method (which is part of the {@link List} interface).
625       */
626      public synchronized void removeAllElements() {
627          modCount++;
# Line 655 | Line 666 | public class Vector<E>
666       * correct order; the runtime type of the returned array is that of the
667       * specified array.  If the Vector fits in the specified array, it is
668       * returned therein.  Otherwise, a new array is allocated with the runtime
669 <     * type of the specified array and the size of this Vector.<p>
669 >     * type of the specified array and the size of this Vector.
670       *
671 <     * If the Vector fits in the specified array with room to spare
671 >     * <p>If the Vector fits in the specified array with room to spare
672       * (i.e., the array has more elements than the Vector),
673       * the element in the array immediately following the end of the
674       * Vector is set to null.  (This is useful in determining the length
# Line 668 | Line 679 | public class Vector<E>
679       *          be stored, if it is big enough; otherwise, a new array of the
680       *          same runtime type is allocated for this purpose.
681       * @return an array containing the elements of the Vector
682 <     * @exception ArrayStoreException the runtime type of a is not a supertype
682 >     * @throws ArrayStoreException if the runtime type of a is not a supertype
683       * of the runtime type of every element in this Vector
684       * @throws NullPointerException if the given array is null
685       * @since 1.2
# Line 692 | Line 703 | public class Vector<E>
703       *
704       * @param index index of the element to return
705       * @return object at the specified index
706 <     * @exception ArrayIndexOutOfBoundsException index is out of range (index
707 <     *            &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 get(int index) {
# Line 710 | Line 721 | public class Vector<E>
721       * @param index index of the element to replace
722       * @param element element to be stored at the specified position
723       * @return the element previously at the specified position
724 <     * @exception ArrayIndexOutOfBoundsException index out of range
725 <     *            (index &lt; 0 || index &gt;= size())
724 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
725 >     *         ({@code index < 0 || index >= size()})
726       * @since 1.2
727       */
728      public synchronized E set(int index, E element) {
# Line 759 | Line 770 | public class Vector<E>
770       *
771       * @param index index at which the specified element is to be inserted
772       * @param element element to be inserted
773 <     * @exception ArrayIndexOutOfBoundsException index is out of range
774 <     *            (index &lt; 0 || index &gt; size())
773 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
774 >     *         ({@code index < 0 || index > size()})
775       * @since 1.2
776       */
777      public void add(int index, E element) {
# Line 772 | Line 783 | public class Vector<E>
783       * Shifts any subsequent elements to the left (subtracts one from their
784       * indices).  Returns the element that was removed from the Vector.
785       *
786 <     * @exception ArrayIndexOutOfBoundsException index out of range (index
787 <     *            &lt; 0 || index &gt;= size())
786 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
787 >     *         ({@code index < 0 || index >= size()})
788       * @param index the index of the element to be removed
789       * @return element that was removed
790       * @since 1.2
# Line 892 | Line 903 | public class Vector<E>
903       *              specified collection
904       * @param c elements to be inserted into this Vector
905       * @return {@code true} if this Vector changed as a result of the call
906 <     * @exception ArrayIndexOutOfBoundsException index out of range (index
907 <     *            &lt; 0 || index &gt; size())
906 >     * @throws ArrayIndexOutOfBoundsException if the index is out of range
907 >     *         ({@code index < 0 || index > size()})
908       * @throws NullPointerException if the specified collection is null
909       * @since 1.2
910       */
# Line 1040 | Line 1051 | public class Vector<E>
1051  
1052      /**
1053       * Streamlined specialization of AbstractList version of iterator.
1054 <     * Locally perfroms bounds checks, but relies on outer Vector
1054 >     * Locally performs bounds checks, but relies on outer Vector
1055       * to access elements under synchronization.
1056       */
1057      private final class VectorIterator implements ListIterator<E> {
# Line 1145 | Line 1156 | public class Vector<E>
1156       * equal, the returned List is empty.)  The returned List is backed by this
1157       * List, so changes in the returned List are reflected in this List, and
1158       * vice-versa.  The returned List supports all of the optional List
1159 <     * operations supported by this List.<p>
1159 >     * operations supported by this List.
1160       *
1161 <     * This method eliminates the need for explicit range operations (of
1161 >     * <p>This method eliminates the need for explicit range operations (of
1162       * the sort that commonly exist for arrays).   Any operation that expects
1163       * a List can be used as a range operation by operating on a subList view
1164       * instead of a whole List.  For example, the following idiom
# Line 1157 | Line 1168 | public class Vector<E>
1168       * </pre>
1169       * Similar idioms may be constructed for indexOf and lastIndexOf,
1170       * and all of the algorithms in the Collections class can be applied to
1171 <     * a subList.<p>
1171 >     * a subList.
1172       *
1173 <     * The semantics of the List returned by this method become undefined if
1173 >     * <p>The semantics of the List returned by this method become undefined if
1174       * the backing list (i.e., this List) is <i>structurally modified</i> in
1175       * any way other than via the returned List.  (Structural modifications are
1176       * those that change the size of the List, or otherwise perturb it in such
# Line 1168 | Line 1179 | public class Vector<E>
1179       * @param fromIndex low endpoint (inclusive) of the subList
1180       * @param toIndex high endpoint (exclusive) of the subList
1181       * @return a view of the specified range within this List
1182 <     * @throws IndexOutOfBoundsException endpoint index value out of range
1183 <     *         <code>(fromIndex &lt; 0 || toIndex &gt; size)</code>
1184 <     * @throws IllegalArgumentException endpoint indices out of order
1185 <     *         <code>(fromIndex &gt; toIndex)</code>
1182 >     * @throws IndexOutOfBoundsException if an endpoint index value is out of range
1183 >     *         {@code (fromIndex < 0 || toIndex > size)}
1184 >     * @throws IllegalArgumentException if the endpoint indices are out of order
1185 >     *         {@code (fromIndex > toIndex)}
1186       */
1187      public synchronized List<E> subList(int fromIndex, int toIndex) {
1188          return new VectorSubList(this, this, fromIndex, fromIndex, toIndex);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines