193 |
|
* <p>This method is equivalent to {@link #addLast}. |
194 |
|
* |
195 |
|
* @param e element to be appended to this list |
196 |
< |
* @return <tt>true</tt> (as per the spec for {@link Collection#add}) |
196 |
> |
* @return <tt>true</tt> (as specified by {@link Collection#add}) |
197 |
|
*/ |
198 |
|
public boolean add(E e) { |
199 |
|
addBefore(e, header); |
486 |
|
* Adds the specified element as the tail (last element) of this list. |
487 |
|
* |
488 |
|
* @param e the element to add |
489 |
< |
* @return <tt>true</tt> (as per the spec for {@link Queue#offer}) |
489 |
> |
* @return <tt>true</tt> (as specified by {@link Queue#offer}) |
490 |
|
* @since 1.5 |
491 |
|
*/ |
492 |
|
public boolean offer(E e) { |
498 |
|
* Inserts the specified element at the front of this list. |
499 |
|
* |
500 |
|
* @param e the element to insert |
501 |
< |
* @return <tt>true</tt> (as per the spec for {@link Deque#offerFirst}) |
501 |
> |
* @return <tt>true</tt> (as specified by {@link Deque#offerFirst}) |
502 |
|
* @since 1.6 |
503 |
|
*/ |
504 |
|
public boolean offerFirst(E e) { |
510 |
|
* Inserts the specified element at the end of this list. |
511 |
|
* |
512 |
|
* @param e the element to insert |
513 |
< |
* @return <tt>true</tt> (as per the spec for {@link Deque#offerLast}) |
513 |
> |
* @return <tt>true</tt> (as specified by {@link Deque#offerLast}) |
514 |
|
* @since 1.6 |
515 |
|
*/ |
516 |
|
public boolean offerLast(E e) { |
547 |
|
} |
548 |
|
|
549 |
|
/** |
550 |
< |
* Retrieves and removes the first element of this list, or |
551 |
< |
* <tt>null</tt> if this list is empty. |
550 |
> |
* Retrieves and removes the first element of this list, |
551 |
> |
* or returns <tt>null</tt> if this list is empty. |
552 |
|
* |
553 |
|
* @return the first element of this list, or <tt>null</tt> if |
554 |
|
* this list is empty |
561 |
|
} |
562 |
|
|
563 |
|
/** |
564 |
< |
* Retrieves and removes the last element of this list, or |
565 |
< |
* <tt>null</tt> if this list is empty. |
564 |
> |
* Retrieves and removes the last element of this list, |
565 |
> |
* or returns <tt>null</tt> if this list is empty. |
566 |
|
* |
567 |
|
* @return the last element of this list, or <tt>null</tt> if |
568 |
|
* this list is empty |
799 |
|
} |
800 |
|
|
801 |
|
/** |
802 |
+ |
* Returns an iterator over the elements in this list in reverse |
803 |
+ |
* sequential order. The elements will be returned in order from |
804 |
+ |
* last (tail) to first (head). |
805 |
+ |
* |
806 |
+ |
* @return an iterator over the elements in this list in reverse |
807 |
+ |
* sequence |
808 |
+ |
*/ |
809 |
+ |
public Iterator<E> descendingIterator() { |
810 |
+ |
return new DescendingIterator(); |
811 |
+ |
} |
812 |
+ |
|
813 |
+ |
/** Adapter to provide descending iterators via ListItr.previous */ |
814 |
+ |
private class DescendingIterator implements Iterator { |
815 |
+ |
final ListItr itr = new ListItr(size()); |
816 |
+ |
public boolean hasNext() { |
817 |
+ |
return itr.hasPrevious(); |
818 |
+ |
} |
819 |
+ |
public E next() { |
820 |
+ |
return itr.previous(); |
821 |
+ |
} |
822 |
+ |
public void remove() { |
823 |
+ |
itr.remove(); |
824 |
+ |
} |
825 |
+ |
} |
826 |
+ |
|
827 |
+ |
/** |
828 |
|
* Returns a shallow copy of this <tt>LinkedList</tt>. (The elements |
829 |
|
* themselves are not cloned.) |
830 |
|
* |