ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CopyOnWriteArrayList.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CopyOnWriteArrayList.java (file contents):
Revision 1.31 by jsr166, Tue Apr 26 19:54:03 2005 UTC vs.
Revision 1.32 by jsr166, Tue Apr 26 23:46:37 2005 UTC

# Line 70 | Line 70 | public class CopyOnWriteArrayList<E>
70  
71      /**
72       * Creates a list containing the elements of the specified
73 <     * Collection, in the order they are returned by the Collection's
73 >     * collection, in the order they are returned by the collection's
74       * iterator.
75 +     *
76       * @param c the collection of initially held elements
77       */
78      public CopyOnWriteArrayList(Collection<? extends E> c) {
# Line 291 | Line 292 | public class CopyOnWriteArrayList<E>
292       * specified array.  If the list fits in the specified array, it is
293       * returned therein.  Otherwise, a new array is allocated with the runtime
294       * type of the specified array and the size of this list.
295 <     * <p>
296 <     * If the list fits in the specified array with room to spare
297 <     * (i.e., the array has more elements than the list),
298 <     * the element in the array immediately following the end of the
299 <     * collection is set to null.  This is useful in determining the length
300 <     * of the list <em>only</em> if the caller knows that the list
301 <     * does not contain any null elements.
295 >     *
296 >     * <p>If this list fits in the specified array with room to spare
297 >     * (i.e., the array has more elements than this list), the element
298 >     * in the array immediately following the end of the list is set to
299 >     * <tt>null</tt>.  This is useful in determining the length of this
300 >     * list <i>only</i> if the caller knows that this collection does
301 >     * not contain any <tt>null</tt> elements.)
302       *
303       * @param a the array into which the elements of the list are to
304       *            be stored, if it is big enough; otherwise, a new array of the
# Line 368 | Line 369 | public class CopyOnWriteArrayList<E>
369       * Appends the specified element to the end of this list.
370       *
371       * @param element element to be appended to this list.
372 <     * @return true (as per the general contract of Collection.add).
372 >     * @return true (as per the general contract of <tt>Collection.add</tt>).
373       */
374      public synchronized boolean add(E element) {
375          int len = array.length;
# Line 498 | Line 499 | public class CopyOnWriteArrayList<E>
499  
500      /**
501       * Append the element if not present.
502 <     * @param element element to be added to this Collection, if absent.
502 >     * @param element element to be added to this list, if absent.
503       * @return true if added
504       */
505      public synchronized boolean addIfAbsent(E element) {
# Line 519 | Line 520 | public class CopyOnWriteArrayList<E>
520      }
521  
522      /**
523 <     * Returns true if this Collection contains all of the elements in the
524 <     * specified Collection.
525 <     * <p>
526 <     * This implementation iterates over the specified Collection, checking
527 <     * each element returned by the Iterator in turn to see if it's
528 <     * contained in this Collection.  If all elements are so contained
529 <     * true is returned, otherwise false.
523 >     * Returns true if this list contains all of the elements in the
524 >     * specified collection.
525 >     *
526 >     * <p>This implementation iterates over the specified collection,
527 >     * checking each element returned by the Iterator in turn to see if
528 >     * it's contained in this list.  If all elements are so contained
529 >     * <tt>true</tt> is returned, otherwise <tt>false</tt>.
530 >     *
531       * @param c the collection
532       * @return true if all elements are contained
533       */
# Line 542 | Line 544 | public class CopyOnWriteArrayList<E>
544  
545  
546      /**
547 <     * Removes from this Collection all of its elements that are contained in
548 <     * the specified Collection. This is a particularly expensive operation
547 >     * Removes from this list all of its elements that are contained in
548 >     * the specified collection. This is a particularly expensive operation
549       * in this class because of the need for an internal temporary array.
548     * <p>
550       *
551       * @param c the collection
552 <     * @return true if this Collection changed as a result of the call.
552 >     * @return true if this list changed as a result of the call.
553       */
554      public synchronized boolean removeAll(Collection<?> c) {
555          E[] elementData = array;
# Line 575 | Line 576 | public class CopyOnWriteArrayList<E>
576      }
577  
578      /**
579 <     * Retains only the elements in this Collection that are contained in the
580 <     * specified Collection (optional operation).  In other words, removes from
581 <     * this Collection all of its elements that are not contained in the
582 <     * specified Collection.
579 >     * Retains only the elements in this list that are contained in the
580 >     * specified collection (optional operation).  In other words, removes
581 >     * from this list all of its elements that are not contained in the
582 >     * specified collection.
583 >     *
584       * @param c the collection
585 <     * @return true if this Collection changed as a result of the call.
585 >     * @return true if this list changed as a result of the call.
586       */
587      public synchronized boolean retainAll(Collection<?> c) {
588          E[] elementData = array;
# Line 605 | Line 607 | public class CopyOnWriteArrayList<E>
607      }
608  
609      /**
610 <     * Appends all of the elements in the specified Collection that
610 >     * Appends all of the elements in the specified collection that
611       * are not already contained in this list, to the end of
612       * this list, in the order that they are returned by the
613 <     * specified Collection's Iterator.
613 >     * specified collection's iterator.
614       *
615 <     * @param c elements to be added into this list.
615 >     * @param c elements to be added to this list.
616       * @return the number of elements added
617       */
618      public synchronized int addAllAbsent(Collection<? extends E> c) {
# Line 650 | Line 652 | public class CopyOnWriteArrayList<E>
652      }
653  
654      /**
655 <     * Appends all of the elements in the specified Collection to the end of
656 <     * this list, in the order that they are returned by the
657 <     * specified Collection's Iterator.
655 >     * Appends all of the elements in the specified collection to the end
656 >     * of this list, in the order that they are returned by the specified
657 >     * collection's iterator.
658       *
659       * @param c elements to be inserted into this list.
660       * @return true if any elements are added
# Line 761 | Line 763 | public class CopyOnWriteArrayList<E>
763      }
764  
765      /**
766 <     * Returns a string representation of this Collection, containing
766 >     * Returns a string representation of this list, containing
767       * the String representation of each element.
768       */
769      public String toString() {
# Line 839 | Line 841 | public class CopyOnWriteArrayList<E>
841      }
842  
843      /**
844 <     * Returns an Iterator over the elements contained in this collection.
844 >     * Returns an Iterator over the elements contained in this list.
845       * The iterator provides a snapshot of the state of the list
846       * when the iterator was constructed. No synchronization is
847       * needed while traversing the iterator. The iterator does
# Line 938 | Line 940 | public class CopyOnWriteArrayList<E>
940  
941          /**
942           * Not supported. Always throws UnsupportedOperationException.
943 <         * @throws UnsupportedOperationException always; remove is not supported
944 <         *            by this Iterator.
943 >         * @throws UnsupportedOperationException always; <tt>remove</tt>
944 >         *         is not supported by this iterator.
945           */
944
946          public void remove() {
947              throw new UnsupportedOperationException();
948          }
949  
950          /**
951           * Not supported. Always throws UnsupportedOperationException.
952 <         * @throws UnsupportedOperationException always; set is not supported
953 <         *            by this Iterator.
952 >         * @throws UnsupportedOperationException always; <tt>set</tt>
953 >         *         is not supported by this iterator.
954           */
955          public void set(E o) {
956              throw new UnsupportedOperationException();
# Line 957 | Line 958 | public class CopyOnWriteArrayList<E>
958  
959          /**
960           * Not supported. Always throws UnsupportedOperationException.
961 <         * @throws UnsupportedOperationException always; add is not supported
962 <         *            by this Iterator.
961 >         * @throws UnsupportedOperationException always; <tt>add</tt>
962 >         *         is not supported by this iterator.
963           */
964          public void add(E o) {
965              throw new UnsupportedOperationException();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines