233 |
|
* the vector. If the new size is less than the current size, all |
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++; |
461 |
|
/** |
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} |
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 |
< |
* @throws ArrayIndexOutOfBoundsException if the index was invalid |
479 |
< |
* @see #size() |
479 |
< |
* @see List |
480 |
< |
* @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) { |
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 |
< |
* <p>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() |
507 |
< |
* @see #remove(int) |
508 |
< |
* @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++; |
534 |
|
* index is equal to the current size of the vector, the new element |
535 |
|
* is appended to the Vector.) |
536 |
|
* |
537 |
< |
* <p>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() |
547 |
< |
* @see #add(int, Object) |
548 |
< |
* @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++; |
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 #remove(Object)} method (which is part of the |
567 |
> |
* {@link List} interface). |
568 |
|
* |
569 |
|
* @param obj the component to be added |
571 |
– |
* @see #add(Object) |
572 |
– |
* @see List |
570 |
|
*/ |
571 |
|
public synchronized void addElement(E obj) { |
572 |
|
modCount++; |
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) |
584 |
> |
* <p>This method is identical in functionality to the remove(Object) |
585 |
|
* method (which is part of the List interface). |
586 |
|
* |
587 |
|
* @param obj the component to be removed |
601 |
|
} |
602 |
|
|
603 |
|
/** |
604 |
< |
* Removes all components from this vector and sets its size to zero.<p> |
604 |
> |
* Removes all components from this vector and sets its size to zero. |
605 |
|
* |
606 |
< |
* This method is identical in functionality to the clear method |
607 |
< |
* (which is part of the List interface). |
611 |
< |
* |
612 |
< |
* @see #clear |
613 |
< |
* @see List |
606 |
> |
* <p>This method is identical in functionality to the {@link #clear} |
607 |
> |
* method (which is part of the {@link List} interface). |
608 |
|
*/ |
609 |
|
public synchronized void removeAllElements() { |
610 |
|
modCount++; |
649 |
|
* correct order; the runtime type of the returned array is that of the |
650 |
|
* specified array. If the Vector fits in the specified array, it is |
651 |
|
* returned therein. Otherwise, a new array is allocated with the runtime |
652 |
< |
* type of the specified array and the size of this Vector.<p> |
652 |
> |
* type of the specified array and the size of this Vector. |
653 |
|
* |
654 |
< |
* If the Vector fits in the specified array with room to spare |
654 |
> |
* <p>If the Vector fits in the specified array with room to spare |
655 |
|
* (i.e., the array has more elements than the Vector), |
656 |
|
* the element in the array immediately following the end of the |
657 |
|
* Vector is set to null. (This is useful in determining the length |
662 |
|
* be stored, if it is big enough; otherwise, a new array of the |
663 |
|
* same runtime type is allocated for this purpose. |
664 |
|
* @return an array containing the elements of the Vector |
665 |
< |
* @exception ArrayStoreException the runtime type of a is not a supertype |
665 |
> |
* @throws ArrayStoreException if the runtime type of a is not a supertype |
666 |
|
* of the runtime type of every element in this Vector |
667 |
|
* @throws NullPointerException if the given array is null |
668 |
|
* @since 1.2 |
686 |
|
* |
687 |
|
* @param index index of the element to return |
688 |
|
* @return object at the specified index |
689 |
< |
* @exception ArrayIndexOutOfBoundsException index is out of range (index |
690 |
< |
* < 0 || index >= size()) |
689 |
> |
* @throws ArrayIndexOutOfBoundsException if the index is out of range |
690 |
> |
* ({@code index < 0 || index >= size()}) |
691 |
|
* @since 1.2 |
692 |
|
*/ |
693 |
|
public synchronized E get(int index) { |
704 |
|
* @param index index of the element to replace |
705 |
|
* @param element element to be stored at the specified position |
706 |
|
* @return the element previously at the specified position |
707 |
< |
* @exception ArrayIndexOutOfBoundsException index out of range |
708 |
< |
* (index < 0 || index >= size()) |
707 |
> |
* @throws ArrayIndexOutOfBoundsException if the index is out of range |
708 |
> |
* ({@code index < 0 || index >= size()}) |
709 |
|
* @since 1.2 |
710 |
|
*/ |
711 |
|
public synchronized E set(int index, E element) { |
753 |
|
* |
754 |
|
* @param index index at which the specified element is to be inserted |
755 |
|
* @param element element to be inserted |
756 |
< |
* @exception ArrayIndexOutOfBoundsException index is out of range |
757 |
< |
* (index < 0 || index > size()) |
756 |
> |
* @throws ArrayIndexOutOfBoundsException if the index is out of range |
757 |
> |
* ({@code index < 0 || index > size()}) |
758 |
|
* @since 1.2 |
759 |
|
*/ |
760 |
|
public void add(int index, E element) { |
1139 |
|
* equal, the returned List is empty.) The returned List is backed by this |
1140 |
|
* List, so changes in the returned List are reflected in this List, and |
1141 |
|
* vice-versa. The returned List supports all of the optional List |
1142 |
< |
* operations supported by this List.<p> |
1142 |
> |
* operations supported by this List. |
1143 |
|
* |
1144 |
< |
* This method eliminates the need for explicit range operations (of |
1144 |
> |
* <p>This method eliminates the need for explicit range operations (of |
1145 |
|
* the sort that commonly exist for arrays). Any operation that expects |
1146 |
|
* a List can be used as a range operation by operating on a subList view |
1147 |
|
* instead of a whole List. For example, the following idiom |
1151 |
|
* </pre> |
1152 |
|
* Similar idioms may be constructed for indexOf and lastIndexOf, |
1153 |
|
* and all of the algorithms in the Collections class can be applied to |
1154 |
< |
* a subList.<p> |
1154 |
> |
* a subList. |
1155 |
|
* |
1156 |
< |
* The semantics of the List returned by this method become undefined if |
1156 |
> |
* <p>The semantics of the List returned by this method become undefined if |
1157 |
|
* the backing list (i.e., this List) is <i>structurally modified</i> in |
1158 |
|
* any way other than via the returned List. (Structural modifications are |
1159 |
|
* those that change the size of the List, or otherwise perturb it in such |