yogendra-aurospaces / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

Add Iterables#fromEnumeration() #209

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be very useful for the Iterables class to have a utility to
convert an Enumeration into an Iterable.  This would allow Enumerations to
be used in the enhanced for loop:

Enumeration<T> e = ...;

for (T item : Iterables.fromEnumeration(e) {
 // Do something with item
}

Original issue reported on code.google.com by kevin.a....@gmail.com on 22 Jul 2009 at 9:38

GoogleCodeExporter commented 9 years ago
But an Iterable can be iterated many times. An Iterable that threw 
IllegalStateException at the second iteration would be clumsy, clearly it's the 
wrong 
type for something like that. 

Original comment by jim.andreou on 22 Jul 2009 at 9:45

GoogleCodeExporter commented 9 years ago
We won't add such a method to the library, for the reason Jim mentioned.

Original comment by jared.l....@gmail.com on 22 Jul 2009 at 9:59

GoogleCodeExporter commented 9 years ago
Since it's possible some readers aren't aware, I'll add that we do have an
Iterators.forEnumeration() method, which adapts Enumeration to the appropriate 
type.

Original comment by kevin...@gmail.com on 22 Jul 2009 at 10:02

GoogleCodeExporter commented 9 years ago
Fair enough, thanks for your time.

Original comment by kevin.a....@gmail.com on 22 Jul 2009 at 11:35