-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
6
-
generic
-
generic
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; }
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; }
- duplicates
-
JDK-5017904 (coll) Collections.emptyIterator, Collections.emptyEnumeration
- Closed