|
[
Permlink
| « Hide
]
Dusan Chromy added a comment - 01/Jun/06 04:09 AM
Addition of algorithm methods with an Iterator argument
JUnit tests for newly added methods
It just occured to me - in the middle of CollectionUtils-style programming
Imagine you have an input collection of "raw" objects which you transform to something else by applying a Transformer. Now if you're only interested in finding a transformed object that satisfies a given predicate, having an Iterator flavour of find/exists method will allow you write a code like this: Predicate predicate = ... ; This is going to perform better than the workaround: CollectionUtils.find( CollectionUtils.collect( rawList, transformer ), predicate ); Because the latter needs to apply the transformer to all elements in the list, even if the first transformed element satisfies the predicate. BTW, CollectionUtils has been updated in the 4.0 branch to take Iterable as a parameter wherever possible.
But that CollectionUtils.find( CollectionUtils.collect( rawList, transformer ), predicate ); optimisation presents an interesting challenge to doing something similar with Iterables. Considering that IteratorUtils.toList(Iterator) is available, I don't see much value here and would vote WONTFIX. Dissent?
Sorry for the delay in responding to the suggestion to close this
feature request. Unless I am missing something, the functionality provided by creating Attaching Dusan's changes as a patch as it's hard to work with old copies.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||