Add Collections.unmodifiableIterator and related methods

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: core-libs
    • 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.

            Assignee:
            kevin bourrillion
            Reporter:
            Stuart Marks
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: