Agreed - that looks like the optimal solution. -Yonik http://www.lucidimagination.com
On Thu, Jul 16, 2009 at 11:40 AM, Uwe Schindler<u...@thetaphi.de> wrote: > OK, that makes sense: So the example of Yonik should be interpreted like > this (I think this is the optimal solution as it does not use an additional > if-clause to check if the iteration has already started): > > > > class SliceDocIdSetIterator extends DocIdSetIterator { > > private int doc=-1,act,last; > > > > public SliceDocIdSetIterator(int first, int last) { > > this.act=first-1; this.last=last; > > } > > > > public int docID() { > > return doc; > > } > > > > public int nextDoc() throws IOException { > > if (++act>last) act=NO_MORE_DOCS; > > return doc = act; > > } > > > > public int advance(int target) throws IOException { > > act=target; > > if (act>last) act=NO_MORE_DOCS; > > return doc = act; > > } > > } --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org