commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: [collections] Would like to contribute my RangeIterator
Date Tue, 30 Apr 2002 07:59:55 GMT
From: "Oliver Fischer" <plexus@snafu.de>
> 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 );

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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


Mime
View raw message