commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <Joerg.Schai...@scalaris.com>
Subject Re: General API question: returning Iterator, Iterable or even Collection?
Date Mon, 03 Jun 2013 14:15:08 GMT
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.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message