You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Oliver Fischer <pl...@snafu.de> on 2002/05/03 10:55:46 UTC

Re: [collections] Would like to contribute my RangeIterator

After the discussion about it, I decided to post the Rangeiterator.
May you like it.

Bye

Oliver


----- Original Message -----
From: "Jack, Paul" <pj...@sfaf.org>
To: "'Jakarta Commons Developers List'"
<co...@jakarta.apache.org>
Sent: Tuesday, April 30, 2002 7:07 PM
Subject: RE: [collections] Would like to contribute my RangeIterator


> And to use a RangeIterator over a collection that isn't sorted,
> you'd probably create a sorted collection first:
>
>    new TreeSet(collection, comparator).subSet(first,
last).iterator();
>
> seems like it does what RangeIterator does.
>
> -Paul
>
> -----Original Message-----
> From: James Strachan [mailto:james_strachan@yahoo.co.uk]
> Sent: Tuesday, April 30, 2002 1:00 AM
> To: Jakarta Commons Developers List
> Subject: Re: [collections] Would like to contribute my RangeIterator
>
>
> From: "Oliver Fischer" <pl...@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:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
>

Re: [collections] Would like to contribute my RangeIterator

Posted by Oliver Fischer <pl...@snafu.de>.
Sorry, the posted classes contain debug code...

Bye

Oliver

----- Original Message -----
From: "Oliver Fischer" <pl...@snafu.de>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Friday, May 03, 2002 10:55 AM
Subject: Re: [collections] Would like to contribute my RangeIterator


> After the discussion about it, I decided to post the Rangeiterator.
> May you like it.
>
> Bye
>
> Oliver
>
>
> ----- Original Message -----
> From: "Jack, Paul" <pj...@sfaf.org>
> To: "'Jakarta Commons Developers List'"
> <co...@jakarta.apache.org>
> Sent: Tuesday, April 30, 2002 7:07 PM
> Subject: RE: [collections] Would like to contribute my RangeIterator
>
>
> > And to use a RangeIterator over a collection that isn't sorted,
> > you'd probably create a sorted collection first:
> >
> >    new TreeSet(collection, comparator).subSet(first,
> last).iterator();
> >
> > seems like it does what RangeIterator does.
> >
> > -Paul
> >
> > -----Original Message-----
> > From: James Strachan [mailto:james_strachan@yahoo.co.uk]
> > Sent: Tuesday, April 30, 2002 1:00 AM
> > To: Jakarta Commons Developers List
> > Subject: Re: [collections] Would like to contribute my
RangeIterator
> >
> >
> > From: "Oliver Fischer" <pl...@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:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> >
>


----------------------------------------------------------------------
----------


> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>