<p>Personally, I find the range of functionality provided by java.util.Iterator to be fairly pathetic. At a minimum, I'd like to have methods such as:</p>

<ul>
<li>peek() returns next element without moving the iterator forward</li>
<li>previous() returns the previous element</li>
</ul>

<p>Though there are lots of other possibilities such as first() and last().</p>

<p>Does anyone know if such a 3rd party iterator exists? It would probably need to be implemented as a decorator of java.util.Iterator so that it can work with the existing java collections. Ideally, it should be "generics aware".</p>

<p>Thanks in advance,
Don</p>

You can get
```
previous()
```
easily by just using a
```
java.util.ListIterator
```
.
Peek at that point is easily implemented by doing a
```
```
public <T> T peek(ListIterator<T> iter) throws NoSuchElementException {
    T obj = iter.next();
    iter.previous();
    return obj;
}
```
```
Unfortunately it will be easier to have it as a utility method since each collection class implements their own iterators. To do a wrapper to get a peek method on each collection on some interface such as
```
MyListIterator
```
would be quite a lot of work.