RFR(s): 8072726: add adapter to convert Enumeration to Iterator
Claes Redestad
claes.redestad at oracle.com
Sat May 16 23:23:36 UTC 2015
On 2015-05-17 01:02, Remi Forax wrote:
>>
>> So... I'm happy with Stuart's proposal.
>>
>> I would also be happy (happier?) with a stream variant:
>> pc.elements().stream().forEach(this::doSomethingWithPermission);
>
> We are not that far :
> pc.elements().asIterator().forEachRemaining(this::doSomethingWithPermission);
>
Yes, I guess that's no worse. Thanks!
>
> and having a method stream() on an Enumeration as the very same issue
> as having a method stream() on an Iterator.
> A Stream need to know more than just the elements but also
> characteristics like if the element can be null, are ordered, the
> number of elements if known, etc.
> These characteristics can be derived from List or Set but not from
> Iterator/Enumeration easily.
>
> That's why it's better to let the user to create a stream using
> StreamSupport if he really want one.
Right.
/Claes
More information about the core-libs-dev
mailing list