What is the significance of introducing a new named "drop-in" concept into an iterator that already scrolls easily in both directions?
If you really want this, you can simply implement two trivial static helpers:
public static <T> T peekNext(ListIterator<T> iterator) { T next = iterator.next(); iterator.previous(); return next; } public static <T> T peekPrevious(ListIterator<T> iterator) { T previous = iterator.previous(); iterator.next(); return previous; }
source share