commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: [collections] Would like to contribute my RangeIterator
Date Tue, 30 Apr 2002 07:59:55 GMT
From: "Oliver Fischer" <>
> Is there a PredicateIterator already?

Actually its called FilterIterator right now.

> Haven't seen it in the API doc
> for the collections? I think the FilterIterator is quite close to it.
> The my RangeIterator will stop, if the right border is reached, while
> (?) the FilterIterator evaluates every object. Think about iterators
> which point to a huge amount of objects...

Though that assumes that the underlying iterator returns objects sorted (in
the right ascending/descending order) that the left & right predicates are
is based on. This sounds a bit specific to me; maybe this should be done
using an 'Index' class of some kind to mimic the sorting and range features.
For the general approach of filtering an iterator the existing Filterterator
seems fine which works on any Predicates and irrespective of sorting...

Predicate predicate = new Predicate() {
    public boolean evaluate(Object object) {
        Foo foo = (Foo) object;
        return foo.getAge() > 12 and foo.getAge() < 67;
return new FilterIterator( iterator, predicate );


Do You Yahoo!?
Get your free address at

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message