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 |
|
|
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 #add(Object) add(E)} |
567 |
> |
* method (which is part of the {@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) |
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} if the argument was a component of this |
590 |
|
* vector; {@code false} otherwise. |
593 |
– |
* @see List#remove(Object) |
594 |
– |
* @see List |
591 |
|
*/ |
592 |
|
public synchronized boolean removeElement(Object obj) { |
593 |
|
modCount++; |
600 |
|
} |
601 |
|
|
602 |
|
/** |
603 |
< |
* 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). |
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++; |
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 |
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 |
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 |
< |
* < 0 || index >= 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) { |
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 < 0 || index >= 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) { |
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 < 0 || index > 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) { |
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 |
< |
* < 0 || index >= 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 |
885 |
|
* specified collection |
886 |
|
* @param c elements to be inserted into this Vector |
887 |
|
* @return {@code true} if this Vector changed as a result of the call |
888 |
< |
* @exception ArrayIndexOutOfBoundsException index out of range (index |
889 |
< |
* < 0 || index > size()) |
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 |
|
*/ |
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> { |
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 |
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 |
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 < 0 || toIndex > size)</code> |
1166 |
< |
* @throws IllegalArgumentException endpoint indices out of order |
1167 |
< |
* <code>(fromIndex > 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); |