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 |
|
* |