On 2013-06-03, Matt Benson wrote: > On Mon, Jun 3, 2013 at 9:15 AM, Jörg Schaible > <joerg.schai...@scalaris.com>wrote:
>> 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 foreach loop. But there is a >>> risk it uses more memory than necessary. The pros for an Iterator is to >>> be able to stream the data without holding the whole structure in >>> memory. I don't know if that makes a real difference for your use case. >>> An Iterable than can only be iterated once is another solution. >> An Iterable returns only an Iterator, no need to keep anything in memory >> except of an (anonymous) Iterable instance. > +1. I program to Iterable as often as possible. If iteration is all > that is needed, then... um, it's all that is needed. ;) Sounds like my gut feeling of "I'd prefer Iterable" wasn't too far off, then. At least I'm not alone. "The structure" will be a list that is kept in memory anyway for the simple case and a temporary sorted version of it - most likely of length 1 - for the not-quite-so-simple case. Shouldn't make a significant difference. Thanks Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org