RFR(s): 8072726: add adapter to convert Enumeration to Iterator

Peter Levart peter.levart at gmail.com
Tue May 19 09:17:16 UTC 2015


Hi,

On 05/18/2015 12:20 PM, Paul Sandoz wrote:
> Hi Stuart,
>
> I would like to suggest some tweaks to the specification to get across this method is transitioning control of traversal from enumeration to iterator. How about:
>
>    Returns an iterator that traverses the remaining elements covered by this enumeration.
>    Traversal is undefined if this enumeration is operated on after the call to {@code asIterator}.

I suppose this part of specification allows alternative overridden 
implementations of asIterator() method that return Iterator 
implementation that is more optimal in sense of not delegating to the 
Enumeration, but using it's own state, right?

Should anything be said also about default remove() method inherited 
from Iterator interface? Are custom asIterator() implementations allowed 
to return an Iterator that implements remove() in a way that actually 
removes elements?

Regards, Peter




More information about the core-libs-dev mailing list