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

Comparing jsr166/src/main/java/util/ArrayDeque.java (file contents):
Revision 1.9 by jsr166, Mon May 16 06:16:12 2005 UTC vs.
Revision 1.12 by jsr166, Tue May 17 16:14:34 2005 UTC

# Line 313 | Line 313 | public class ArrayDeque<E> extends Abstr
313       * If the deque does not contain the element, it is unchanged.
314       * More formally, removes the first element <tt>e</tt> such that
315       * <tt>o.equals(e)</tt> (if such an element exists).
316 <     * Returns true if this deque contained the specified element (or
317 <     * equivalently, if this deque changed as a result of the call).
316 >     * Returns <tt>true</tt> if this deque contained the specified element
317 >     * (or equivalently, if this deque changed as a result of the call).
318       *
319       * @param o element to be removed from this deque, if present
320       * @return <tt>true</tt> if the deque contained the specified element
# Line 341 | Line 341 | public class ArrayDeque<E> extends Abstr
341       * If the deque does not contain the element, it is unchanged.
342       * More formally, removes the last element <tt>e</tt> such that
343       * <tt>o.equals(e)</tt> (if such an element exists).
344 <     * Returns true if this deque contained the specified element (or
345 <     * equivalently, if this deque changed as a result of the call).
344 >     * Returns <tt>true</tt> if this deque contained the specified element
345 >     * (or equivalently, if this deque changed as a result of the call).
346       *
347       * @param o element to be removed from this deque, if present
348       * @return <tt>true</tt> if the deque contained the specified element
# Line 613 | Line 613 | public class ArrayDeque<E> extends Abstr
613       * If the deque does not contain the element, it is unchanged.
614       * More formally, removes the first element <tt>e</tt> such that
615       * <tt>o.equals(e)</tt> (if such an element exists).
616 <     * Returns true if this deque contained the specified element (or
617 <     * equivalently, if this deque changed as a result of the call).
616 >     * Returns <tt>true</tt> if this deque contained the specified element
617 >     * (or equivalently, if this deque changed as a result of the call).
618       *
619       * <p>This method is equivalent to {@link #removeFirstOccurrence}.
620       *
# Line 645 | Line 645 | public class ArrayDeque<E> extends Abstr
645  
646      /**
647       * Returns an array containing all of the elements in this deque
648 <     * in the correct order.
648 >     * in proper sequence (from first to last element).
649 >     *
650 >     * <p>The returned array will be "safe" in that no references to it are
651 >     * maintained by this deque.  (In other words, this method must allocate
652 >     * a new array).  The caller is thus free to modify the returned array.
653 >     *
654 >     * <p>This method acts as bridge between array-based and collection-based
655 >     * APIs.
656       *
657       * @return an array containing all of the elements in this deque
651     *         in the correct order
658       */
659      public Object[] toArray() {
660          return copyElements(new Object[size()]);
661      }
662  
663      /**
664 <     * Returns an array containing all of the elements in this deque in the
665 <     * correct order; the runtime type of the returned array is that of the
666 <     * specified array.  If the deque fits in the specified array, it is
667 <     * returned therein.  Otherwise, a new array is allocated with the runtime
668 <     * type of the specified array and the size of this deque.
669 <     *
670 <     * <p>If the deque fits in the specified array with room to spare (i.e.,
671 <     * the array has more elements than the deque), the element in the array
672 <     * immediately following the end of the collection is set to <tt>null</tt>.
664 >     * Returns an array containing all of the elements in this deque in
665 >     * proper sequence (from first to last element); the runtime type of the
666 >     * returned array is that of the specified array.  If the deque fits in
667 >     * the specified array, it is returned therein.  Otherwise, a new array
668 >     * is allocated with the runtime type of the specified array and the
669 >     * size of this deque.
670 >     *
671 >     * <p>If this deque fits in the specified array with room to spare
672 >     * (i.e., the array has more elements than this deque), the element in
673 >     * the array immediately following the end of the deque is set to
674 >     * <tt>null</tt>.
675 >     *
676 >     * <p>Like the {@link #toArray()} method, this method acts as bridge between
677 >     * array-based and collection-based APIs.  Further, this method allows
678 >     * precise control over the runtime type of the output array, and may,
679 >     * under certain circumstances, be used to save allocation costs.
680 >     *
681 >     * <p>Suppose <tt>x</tt> is a deque known to contain only strings.
682 >     * The following code can be used to dump the deque into a newly
683 >     * allocated array of <tt>String</tt>:
684 >     *
685 >     * <pre>
686 >     *     String[] y = x.toArray(new String[0]);</pre>
687 >     *
688 >     * Note that <tt>toArray(new Object[0])</tt> is identical in function to
689 >     * <tt>toArray()</tt>.
690       *
691       * @param a the array into which the elements of the deque are to
692       *          be stored, if it is big enough; otherwise, a new array of the
693       *          same runtime type is allocated for this purpose
694 <     * @return an array containing the elements of the deque
695 <     * @throws ArrayStoreException if the runtime type of a is not a supertype
696 <     *         of the runtime type of every element in this deque
694 >     * @return an array containing all of the elements in this deque
695 >     * @throws ArrayStoreException if the runtime type of the specified array
696 >     *         is not a supertype of the runtime type of every element in
697 >     *         this deque
698 >     * @throws NullPointerException if the specified array is null
699       */
700      public <T> T[] toArray(T[] a) {
701          int size = size();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines