You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2006/05/24 00:41:34 UTC

Re: [collections] CollectionUtils vs. IteratorUtils interface

I think that these methods would make useful additions to the API.

I don't have the time to do much collections work these days, but if you 
want to code the methods with test cases and attach them to JIRA then 
that would be great.

Stephen


dusan.chromy@freenet.de wrote:
> I've been using some algorithm methods from the CollectionUtils, for example 
> 
> find(Collection, Predicate)
> exists(Collection, Predicate)
> countMatches(Collection, Predicate)
> forAllDo(Collection, Closure)
> 
> However, I would also like to be able to use these algorithms with an Iterator:
> 
> find(Iterator, Predicate)
> exists(Iterator, Predicate)
> countMatches(Iterator, Predicate)
> forAllDo(Iterator, Closure)
> 
> The obvious workaround is to use IteratorUtils.toList(Iterator), however this comes at the cost of constructing a list object (an ArrayList presumably) which could be avoided, as the Iterator itself is sufficient for the above algorithms to work.
> 
> What do you think? Is there any reason not to provide the algorithms for an Iterator? I personally think that the algorithms should have been there for Iterators in the first place, because every collection is Iterable (or has an Iterator, prior to JDK 5.0).
> 
> If noone is interested or has time to implement these changes, I can also contribute to the project - but at the moment I just wanted to discuss the idea / check if this has been already considered or planned.
> 
> Best Regards,
> 
> Dusan Chromy
> 
> Ihr Traumpartner ist nur einen Klick entfernt. 1 Million Singles warten auf Sie in
> Deutschlands beliebteste Partnerboerse:
> http://singles.freenet.de/index.html?pid=11512
> 

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