91 |
|
* |
92 |
|
* @param toCopyIn the array (a copy of this array is used as the |
93 |
|
* internal array) |
94 |
+ |
* @throws NullPointerException if the specified array is null |
95 |
|
*/ |
96 |
|
public CopyOnWriteArrayList(E[] toCopyIn) { |
97 |
|
copyIn(toCopyIn, 0, toCopyIn.length); |
513 |
|
|
514 |
|
/** |
515 |
|
* Append the element if not present. |
516 |
+ |
* |
517 |
|
* @param element element to be added to this list, if absent |
518 |
< |
* @return true if added |
518 |
> |
* @return <tt>true</tt> if the element was added |
519 |
|
*/ |
520 |
|
public synchronized boolean addIfAbsent(E element) { |
521 |
|
// Copy while checking if already present. |
542 |
|
* @return <tt>true</tt> if this list contains all of the elements of the |
543 |
|
* specified collection |
544 |
|
* @throws NullPointerException if the specified collection is null |
545 |
+ |
* @see #contains(Object) |
546 |
|
*/ |
547 |
|
public boolean containsAll(Collection<?> c) { |
548 |
|
E[] elementData = array(); |
562 |
|
* |
563 |
|
* @param c collection containing elements to be removed from this list |
564 |
|
* @return <tt>true</tt> if this list changed as a result of the call |
565 |
< |
* @throws ClassCastException {@inheritDoc} |
566 |
< |
* @throws NullPointerException {@inheritDoc} |
565 |
> |
* @throws ClassCastException if the class of an element of this list |
566 |
> |
* is incompatible with the specified collection (optional) |
567 |
> |
* @throws NullPointerException if this list contains a null element and the |
568 |
> |
* specified collection does not permit null elements (optional), |
569 |
> |
* or if the specified collection is null |
570 |
> |
* @see #remove(Object) |
571 |
|
*/ |
572 |
|
public synchronized boolean removeAll(Collection<?> c) { |
573 |
|
E[] elementData = array; |
600 |
|
* |
601 |
|
* @param c collection containing elements to be retained in this list |
602 |
|
* @return <tt>true</tt> if this list changed as a result of the call |
603 |
< |
* @throws ClassCastException {@inheritDoc} |
604 |
< |
* @throws NullPointerException {@inheritDoc} |
603 |
> |
* @throws ClassCastException if the class of an element of this list |
604 |
> |
* is incompatible with the specified collection (optional) |
605 |
> |
* @throws NullPointerException if this list contains a null element and the |
606 |
> |
* specified collection does not permit null elements (optional), |
607 |
> |
* or if the specified collection is null |
608 |
> |
* @see #remove(Object) |
609 |
|
*/ |
610 |
|
public synchronized boolean retainAll(Collection<?> c) { |
611 |
|
E[] elementData = array; |
638 |
|
* @param c collection containing elements to be added to this list |
639 |
|
* @return the number of elements added |
640 |
|
* @throws NullPointerException if the specified collection is null |
641 |
+ |
* @see #addIfAbsent(Object) |
642 |
|
*/ |
643 |
|
public synchronized int addAllAbsent(Collection<? extends E> c) { |
644 |
|
int numNew = c.size(); |
670 |
|
|
671 |
|
/** |
672 |
|
* Removes all of the elements from this list. |
673 |
< |
* |
673 |
> |
* The list will be empty after this call returns. |
674 |
|
*/ |
675 |
|
public synchronized void clear() { |
676 |
|
array = (E[]) new Object[0]; |
682 |
|
* collection's iterator. |
683 |
|
* |
684 |
|
* @param c collection containing elements to be added to this list |
685 |
< |
* @return true if any elements are added |
685 |
> |
* @return <tt>true</tt> if this list changed as a result of the call |
686 |
|
* @throws NullPointerException if the specified collection is null |
687 |
+ |
* @see #add(Object) |
688 |
|
*/ |
689 |
|
public synchronized boolean addAll(Collection<? extends E> c) { |
690 |
|
int numNew = c.size(); |
706 |
|
* list, starting at the specified position. Shifts the element |
707 |
|
* currently at that position (if any) and any subsequent elements to |
708 |
|
* the right (increases their indices). The new elements will appear |
709 |
< |
* in the list in the order that they are returned by the |
710 |
< |
* specified Collection's iterator. |
709 |
> |
* in this list in the order that they are returned by the |
710 |
> |
* specified collection's iterator. |
711 |
|
* |
712 |
|
* @param index index at which to insert the first element |
713 |
|
* from the specified collection |
715 |
|
* @return <tt>true</tt> if this list changed as a result of the call |
716 |
|
* @throws IndexOutOfBoundsException {@inheritDoc} |
717 |
|
* @throws NullPointerException if the specified collection is null |
718 |
+ |
* @see #add(int,Object) |
719 |
|
*/ |
720 |
|
public synchronized boolean addAll(int index, Collection<? extends E> c) { |
721 |
|
int len = array.length; |