6 |
|
*/ |
7 |
|
|
8 |
|
package java.util; |
9 |
+ |
import java.util.*; // for javadoc |
10 |
|
|
11 |
|
/** |
12 |
|
* Linked list implementation of the <tt>List</tt> interface. Implements all |
93 |
|
* @param c the collection whose elements are to be placed into this list |
94 |
|
* @throws NullPointerException if the specified collection is null |
95 |
|
*/ |
96 |
< |
public LinkedList(Collection<? extends E> c) { |
97 |
< |
this(); |
98 |
< |
addAll(c); |
99 |
< |
} |
96 |
> |
public LinkedList(Collection<? extends E> c) { |
97 |
> |
this(); |
98 |
> |
addAll(c); |
99 |
> |
} |
100 |
|
|
101 |
|
/** |
102 |
|
* Returns the first element in this list. |
145 |
|
} |
146 |
|
|
147 |
|
/** |
148 |
< |
* Inserts the given element at the beginning of this list. |
148 |
> |
* Inserts the specified element at the beginning of this list. |
149 |
|
* |
150 |
< |
* @param e the element to be inserted at the beginning of this list |
150 |
> |
* @param e the element to add |
151 |
|
*/ |
152 |
|
public void addFirst(E e) { |
153 |
|
addBefore(e, header.next); |
154 |
|
} |
155 |
|
|
156 |
|
/** |
157 |
< |
* Appends the given element to the end of this list. (Identical in |
157 |
< |
* function to the <tt>add</tt> method; included only for consistency.) |
157 |
> |
* Appends the specified element to the end of this list. |
158 |
|
* |
159 |
< |
* @param e the element to be inserted at the end of this list |
159 |
> |
* <p>This method is equivalent to {@link #add}. |
160 |
> |
* |
161 |
> |
* @param e the element to add |
162 |
|
*/ |
163 |
|
public void addLast(E e) { |
164 |
|
addBefore(e, header); |
189 |
|
/** |
190 |
|
* Appends the specified element to the end of this list. |
191 |
|
* |
192 |
+ |
* <p>This method is equivalent to {@link #addLast}. |
193 |
+ |
* |
194 |
|
* @param e element to be appended to this list |
195 |
|
* @return <tt>true</tt> (as per the spec for {@link Collection#add}) |
196 |
|
*/ |
236 |
|
* this list, in the order that they are returned by the specified |
237 |
|
* collection's iterator. The behavior of this operation is undefined if |
238 |
|
* the specified collection is modified while the operation is in |
239 |
< |
* progress. (This implies that the behavior of this call is undefined if |
240 |
< |
* the specified Collection is this list, and this list is nonempty.) |
239 |
> |
* progress. (Note that this will occur if the specified collection is |
240 |
> |
* this list, and it's nonempty.) |
241 |
|
* |
242 |
|
* @param c collection containing elements to be added to this list |
243 |
|
* @return <tt>true</tt> if this list changed as a result of the call |
625 |
|
*/ |
626 |
|
public boolean removeLastOccurrence(Object o) { |
627 |
|
if (o==null) { |
628 |
< |
for (Entry e = header.previous; e != header; e = e.previous) { |
628 |
> |
for (Entry<E> e = header.previous; e != header; e = e.previous) { |
629 |
|
if (e.element==null) { |
630 |
|
remove(e); |
631 |
|
return true; |
632 |
|
} |
633 |
|
} |
634 |
|
} else { |
635 |
< |
for (Entry e = header.previous; e != header; e = e.previous) { |
635 |
> |
for (Entry<E> e = header.previous; e != header; e = e.previous) { |
636 |
|
if (o.equals(e.element)) { |
637 |
|
remove(e); |
638 |
|
return true; |
831 |
|
* <p>The returned array will be "safe" in that no references to it are |
832 |
|
* maintained by this list. (In other words, this method must allocate |
833 |
|
* a new array). The caller is thus free to modify the returned array. |
834 |
< |
* |
834 |
> |
* |
835 |
|
* <p>This method acts as bridge between array-based and collection-based |
836 |
|
* APIs. |
837 |
|
* |