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 |
|
|
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 |
< |
* <p>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++; |
562 |
|
* increasing its size by one. The capacity of this vector is |
563 |
|
* increased if its size becomes greater than its capacity. |
564 |
|
* |
565 |
< |
* <p>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++; |
581 |
|
* object's index is shifted downward to have an index one smaller |
582 |
|
* than the value it had previously. |
583 |
|
* |
584 |
< |
* <p>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> |
603 |
> |
* Removes all components from this vector and sets its size to zero. |
604 |
|
* |
605 |
< |
* This method is identical in functionality to the clear method |
606 |
< |
* (which is part of the List interface). |
611 |
< |
* |
612 |
< |
* @see #clear |
613 |
< |
* @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++; |
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 |
< |
* @throws 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> { |
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); |