Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8345443

Add Collections.unmodifiableIterator and related methods

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • 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.

            kbourril kevin bourrillion
            smarks Stuart Marks
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: