Sounds like this is a good solution. This skip method should be useful in other places too.
Cezar On Tue, Jan 5, 2010 at 1:14 PM, Vinayak Borkar <[email protected]> wrote: > Till, > > > On further thought, I think I have a better solution -- one that is more > general and does not require any compiler support. > > Add a method to the iterator of the form > > int skip(int len); > > The contract would be that skip tries to skip len items and returns len - n > as the return value where n is the number of items it could actually skip > (Can be < len, if it reached end-of-sequence). > > The default implementation could be: > > while(len-- > 0 && in.next() != null); > return len + 1; > > The iterator of the Sequence could do this in a smarter way. > > The second part is the use of skip in subsequence. > > This will give us the speed improvement for the query. > > What do you think? > > Vinayak > >
