RFR(s): 8072726: add adapter to convert Enumeration to Iterator (original) (raw)
Remi Forax forax at univ-mlv.fr
Sat May 16 22:00:06 UTC 2015
- Previous message: RFR(s): 8072726: add adapter to convert Enumeration to Iterator
- Next message: RFR(s): 8072726: add adapter to convert Enumeration to Iterator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Stuart, this change is pretty cool,
In the javadoc of Iterator instead of: Iterable permsIterable = () -> pc.elements().asIterator(); one can write: Iterable permsIterable = pc.elements()::asIterator;
and I wonder if an example with NetworkInterface.getNetworkInterfaces() is not better, I'm not sure a lot of people have to play with permissions outside people of this list.
and for the implementation of asIterator, I think the code can be written like this: default Iterator asIterator() { return new Iterator<>() { @Override public boolean hasNext() { return hasMoreElements(); } @Override public E next() { return nextElement(); } }; }
using diamond inference on inner-classes (I think the patch that allows that was integrated) and making calls to Enumeration.this implicit.
regards, Rémi
On 05/16/2015 02:37 AM, Stuart Marks wrote:
Hi all,
Please review this small API enhancement to add a default method "asIterator()" to Enumeration that converts it into an Iterator. Webrev: http://cr.openjdk.java.net/~smarks/reviews/8072726/webrev.0/ Bug: https://bugs.openjdk.java.net/browse/JDK-8072726 Thanks, s'marks
- Previous message: RFR(s): 8072726: add adapter to convert Enumeration to Iterator
- Next message: RFR(s): 8072726: add adapter to convert Enumeration to Iterator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]