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

Comparing jsr166/src/main/java/util/LinkedList.java (file contents):
Revision 1.28 by jsr166, Mon May 16 05:17:07 2005 UTC vs.
Revision 1.29 by jsr166, Tue May 17 04:09:23 2005 UTC

# Line 375 | Line 375 | public class LinkedList<E>
375      // Search Operations
376  
377      /**
378 <     * Returns the index in this list of the first occurrence of the
379 <     * specified element, or -1 if the List does not contain this
380 <     * element.  More formally, returns the lowest index i such that
381 <     * <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>, or -1 if
382 <     * there is no such index.
378 >     * Returns the index of the first occurrence of the specified element
379 >     * in this list, or -1 if this list does not contain the element.
380 >     * More formally, returns the lowest index <tt>i</tt> such that
381 >     * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
382 >     * or -1 if there is no such index.
383       *
384       * @param o element to search for
385 <     * @return the index in this list of the first occurrence of the
386 <     *         specified element, or -1 if the list does not contain this
387 <     *         element
385 >     * @return the index of the first occurrence of the specified element in
386 >     *         this list, or -1 if this list does not contain the element
387       */
388      public int indexOf(Object o) {
389          int index = 0;
# Line 405 | Line 404 | public class LinkedList<E>
404      }
405  
406      /**
407 <     * Returns the index in this list of the last occurrence of the
408 <     * specified element, or -1 if the list does not contain this
409 <     * element.  More formally, returns the highest index i such that
410 <     * <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>, or -1 if
411 <     * there is no such index.
407 >     * Returns the index of the last occurrence of the specified element
408 >     * in this list, or -1 if this list does not contain the element.
409 >     * More formally, returns the highest index <tt>i</tt> such that
410 >     * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
411 >     * or -1 if there is no such index.
412       *
413       * @param o element to search for
414 <     * @return the index in this list of the last occurrence of the
415 <     *         specified element, or -1 if the list does not contain this
417 <     *         element
414 >     * @return the index of the last occurrence of the specified element in
415 >     *         this list, or -1 if this list does not contain the element
416       */
417      public int lastIndexOf(Object o) {
418          int index = size;
# Line 824 | Line 822 | public class LinkedList<E>
822  
823      /**
824       * Returns an array containing all of the elements in this list
825 <     * in the correct order.
825 >     * in proper sequence (from first to last element).
826       *
827 +     * <p>The returned array will be "safe" in that no references to it are
828 +     * maintained by this list.  (In other words, this method must allocate
829 +     * a new array).  The caller is thus free to modify the returned array.
830 +     *
831       * @return an array containing all of the elements in this list
832 <     *         in the correct order
832 >     *         in proper sequence
833       */
834      public Object[] toArray() {
835          Object[] result = new Object[size];
# Line 839 | Line 841 | public class LinkedList<E>
841  
842      /**
843       * Returns an array containing all of the elements in this list in
844 <     * the correct order; the runtime type of the returned array is that of
845 <     * the specified array.  If the list fits in the specified array, it
846 <     * is returned therein.  Otherwise, a new array is allocated with the
847 <     * runtime type of the specified array and the size of this list.<p>
848 <     *
849 <     * If the list fits in the specified array with room to spare
850 <     * (i.e., the array has more elements than the list),
851 <     * the element in the array immediately following the end of the
852 <     * collection is set to null.  This is useful in determining the length
853 <     * of the list <i>only</i> if the caller knows that the list
854 <     * does not contain any null elements.
844 >     * proper sequence (from first to last element); the runtime type of
845 >     * the returned array is that of the specified array.  If the list fits
846 >     * in the specified array, it is returned therein.  Otherwise, a new
847 >     * array is allocated with the runtime type of the specified array and
848 >     * the size of this list.
849 >     *
850 >     * <p>If the list fits in the specified array with room to spare (i.e.,
851 >     * the array has more elements than the list), the element in the array
852 >     * immediately following the end of the list is set to <tt>null</tt>.
853 >     * (This is useful in determining the length of the list <i>only</i> if
854 >     * the caller knows that the list does not contain any null elements.)
855 >     *
856 >     * <p>Like the {@link #toArray()} method, this method acts as bridge between
857 >     * array-based and collection-based APIs.  Further, this method allows
858 >     * precise control over the runtime type of the output array, and may,
859 >     * under certain circumstances, be used to save allocation costs.
860 >     *
861 >     * <p>Suppose <tt>x</tt> is a list known to contain only strings.
862 >     * The following code can be used to dump the list into a newly
863 >     * allocated array of <tt>String</tt>:
864 >     *
865 >     * <pre>
866 >     *     String[] y = x.toArray(new String[0]);</pre>
867 >     *
868 >     * Note that <tt>toArray(new Object[0])</tt> is identical in function to
869 >     * <tt>toArray()</tt>.
870       *
871       * @param a the array into which the elements of the list are to
872       *          be stored, if it is big enough; otherwise, a new array of the
873       *          same runtime type is allocated for this purpose.
874       * @return an array containing the elements of the list
875 <     * @throws ArrayStoreException if the runtime type of a is not a
876 <     *         supertype of the runtime type of every element in this list
875 >     * @throws ArrayStoreException if the runtime type of the specified array
876 >     *         is not a supertype of the runtime type of every element in
877 >     *         this list
878       * @throws NullPointerException if the specified array is null
879       */
880      public <T> T[] toArray(T[] a) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines