-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
None
It's fairly common, when creating unmodifiable collections or wrappers, to convert an instance of an existing Iterator implementation into an unmodifiable one. The main value add is that the remove() method throws UOE, while other methods are simply forwarded to the wrapped Iterator. There is at least one instance of this as a private implementation in the JDK. It would be useful to make it public.
It might also apply to Iterable and ListIterator, though the value of these other two is somewhat less clear. Candidates are:
<T> Iterator<T> unmodifiableIterator(Iterator<T> it)
<T> Iterable<T> unmodifiableIterable(Iterable<T> it)
<T> ListIterator<T> unmodifiableListIterator(ListIterator<T> it)
They're probably static methods on java.util.Collections.
It might also apply to Iterable and ListIterator, though the value of these other two is somewhat less clear. Candidates are:
<T> Iterator<T> unmodifiableIterator(Iterator<T> it)
<T> Iterable<T> unmodifiableIterable(Iterable<T> it)
<T> ListIterator<T> unmodifiableListIterator(ListIterator<T> it)
They're probably static methods on java.util.Collections.
- relates to
-
JDK-7001877 (coll) make Collections.singletonIterator() public
- Closed