commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Fischer" <ple...@snafu.de>
Subject Re: [collections] Would like to contribute my RangeIterator
Date Tue, 30 Apr 2002 07:43:14 GMT
Is there a PredicateIterator already? 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...

Bye

Oliver

----- Original Message -----
From: "Tim Vernum" <Tim.Vernum@macquarie.com>
To: "'Jakarta Commons Developers List'"
<commons-dev@jakarta.apache.org>
Sent: Tuesday, April 30, 2002 9:03 AM
Subject: RE: [collections] Would like to contribute my RangeIterator


>
> > final Predicate leftBoder = new Predicate() {
> >       public boolean evaluate(Object input)
> >       {
> >            Member o = (Member)input;
> >            return member.getAge() < 18;
> >       }};
> >
> > final Predicate rightBorder = new Predicate() {
> >       public boolean evaluate(Object input)
> >       {
> >            Member o = (Member)input;
> >            return member.getAge() > 65;
> >       }
> >
> > Iterator i = new RangeIterator(leftBoder, sourceiterator,
> > rightBorder);
>
> Isn't this just a PredicateIterator with a composite predicate ?
>
> class AndPredicate extends Predicate
> {
> private Predicate p1 , p2 ;
>
> AndPredicate( Predicate a, Predicate b )
> {
> p1 = a ;
> p2 = b ;
> }
>
> public boolean evaluate( Object input )
>       {
>           return p1.evaluate( input ) && p2.evaluate( input ) ;
>       }
> }
>
> Iterator i = new PredicateIterator( sourceiterator , new
AndIterator( leftBorder , rightBorder ) ) ;
>
> (although the logic in your border predicates would need to be
reversed in this case, or add in
> a NotPredicate)
>
> Not sure how much of that is in Collections already, but really the
RangeIterator is
> just a specific PredicateIterator, just like the TypedList was
really a PredicateList.
>
>
> NOTICE
> This e-mail and any attachments are confidential and may contain
copyright material of Macquarie Bank or third parties. If you are not
the intended recipient of this email you should not read, print,
re-transmit, store or act in reliance on this e-mail or any
attachments, and should destroy all copies of them. Macquarie Bank
does not guarantee the integrity of any emails or any attached files.
The views or opinions expressed are the author's own and may not
reflect the views or opinions of Macquarie Bank.
>
>
> --
> To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>
>
>
>


--
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