(coll) Collections.EmptyList could override iterator for improved performance

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 6
    • Component/s: core-libs

      The private class EmptyList of java.util.Collections could override iterator
      and perhaps improve performance of the enhanced for loop.

      Simply add this to the class:

      private static Iterator<?> iterator = new Iterator() {
          public boolean hasNext() { return false; }
          public Object next() { throw new NoSuchElementException(); }
          public void remove() { throw new UnsupportedOperationException(); }
      }
      public Iterator iterator() { return iterator; }

            Assignee:
            Martin Buchholz
            Reporter:
            Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: