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.10 by jsr166, Tue May 17 04:09:23 2005 UTC

# 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       * @return an array containing all of the elements in this deque
651     *         in the correct order
655       */
656      public Object[] toArray() {
657          return copyElements(new Object[size()]);
658      }
659  
660      /**
661 <     * Returns an array containing all of the elements in this deque in the
662 <     * correct order; the runtime type of the returned array is that of the
663 <     * specified array.  If the deque fits in the specified array, it is
664 <     * returned therein.  Otherwise, a new array is allocated with the runtime
665 <     * type of the specified array and the size of this deque.
666 <     *
667 <     * <p>If the deque fits in the specified array with room to spare (i.e.,
668 <     * the array has more elements than the deque), the element in the array
669 <     * immediately following the end of the collection is set to <tt>null</tt>.
661 >     * Returns an array containing all of the elements in this deque in
662 >     * proper sequence (from first to last element); the runtime type of the
663 >     * returned array is that of the specified array.  If the deque fits in
664 >     * the specified array, it is returned therein.  Otherwise, a new array
665 >     * is allocated with the runtime type of the specified array and the
666 >     * size of this deque.
667 >     *
668 >     * <p>If this deque fits in the specified array with room to spare
669 >     * (i.e., the array has more elements than this deque), the element in
670 >     * the array immediately following the end of the deque is set to
671 >     * <tt>null</tt>.
672 >     *
673 >     * <p>Like the {@link #toArray()} method, this method acts as bridge between
674 >     * array-based and collection-based APIs.  Further, this method allows
675 >     * precise control over the runtime type of the output array, and may,
676 >     * under certain circumstances, be used to save allocation costs.
677 >     *
678 >     * <p>Suppose <tt>x</tt> is a deque known to contain only strings.
679 >     * The following code can be used to dump the deque into a newly
680 >     * allocated array of <tt>String</tt>:
681 >     *
682 >     * <pre>
683 >     *     String[] y = x.toArray(new String[0]);</pre>
684 >     *
685 >     * Note that <tt>toArray(new Object[0])</tt> is identical in function to
686 >     * <tt>toArray()</tt>.
687       *
688       * @param a the array into which the elements of the deque are to
689       *          be stored, if it is big enough; otherwise, a new array of the
690       *          same runtime type is allocated for this purpose
691 <     * @return an array containing the elements of the deque
692 <     * @throws ArrayStoreException if the runtime type of a is not a supertype
693 <     *         of the runtime type of every element in this deque
691 >     * @return an array containing all of the elements in this deque
692 >     * @throws ArrayStoreException if the runtime type of the specified array
693 >     *         is not a supertype of the runtime type of every element in
694 >     *         this deque
695 >     * @throws NullPointerException if the specified array is null
696       */
697      public <T> T[] toArray(T[] a) {
698          int size = size();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines