General API question: returning Iterator, Iterable or even Collection?

2013-06-03 Thread Stefan Bodewig
Hi, in compress I've added a method to ZipFile that provides access to a subset of the entries. It already contained a method returning an Enumeration of all entries - Enumeration as it mimics java.util.ZipFile which was invented in Java 1.0. For this new method I've chosen to return an

Re: General API question: returning Iterator, Iterable or even Collection?

2013-06-03 Thread Gary Gregory
Why not have the class implement Iterable? Gary On Jun 3, 2013, at 7:45, Stefan Bodewig bode...@apache.org wrote: Iterable - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail:

Re: General API question: returning Iterator, Iterable or even Collection?

2013-06-03 Thread Stefan Bodewig
On 2013-06-03, Gary Gregory wrote: Why not have the class implement Iterable? Oh, I'm returning just a subset, so making the whole class iterable doesn't make sense. I'm talking about public IteratorZipArchiveEntry getEntries(String name) Stefan PS: For the general case of all entries

Re: General API question: returning Iterator, Iterable or even Collection?

2013-06-03 Thread Emmanuel Bourg
Le 03/06/2013 13:44, Stefan Bodewig a écrit : My personal preference would be Iterable as well as the consumer may iterate over the return value multiple times without copying stuff around, but I may be missing something. I like Iterable for the ease of use in a foreach loop. But there is a

Re: General API question: returning Iterator, Iterable or even Collection?

2013-06-03 Thread Jörg Schaible
Emmanuel Bourg wrote: Le 03/06/2013 13:44, Stefan Bodewig a écrit : My personal preference would be Iterable as well as the consumer may iterate over the return value multiple times without copying stuff around, but I may be missing something. I like Iterable for the ease of use in a

Re: General API question: returning Iterator, Iterable or even Collection?

2013-06-03 Thread Matt Benson
On Mon, Jun 3, 2013 at 9:15 AM, Jörg Schaible joerg.schai...@scalaris.comwrote: Emmanuel Bourg wrote: Le 03/06/2013 13:44, Stefan Bodewig a écrit : My personal preference would be Iterable as well as the consumer may iterate over the return value multiple times without copying stuff

Re: General API question: returning Iterator, Iterable or even Collection?

2013-06-03 Thread Stefan Bodewig
On 2013-06-03, Matt Benson wrote: On Mon, Jun 3, 2013 at 9:15 AM, Jörg Schaible joerg.schai...@scalaris.comwrote: Emmanuel Bourg wrote: Le 03/06/2013 13:44, Stefan Bodewig a écrit : My personal preference would be Iterable as well as the consumer may iterate over the return value