This Impl should do it. The problem is, if (last==Integer.MAX_VALUE), then it would break because of overflow.
----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: ysee...@gmail.com [mailto:ysee...@gmail.com] On Behalf Of Yonik > Seeley > Sent: Wednesday, July 15, 2009 11:12 PM > To: java-dev@lucene.apache.org > Subject: DISI semantics > > Is this implementation of an iterator that returns documents between > first and last correct? > Going strictly by the javadoc, it's not... (docID specifically) but it > seems like it should be? > Is there anything in Lucene that this implementation would break? > > class SliceDocIdSetIterator extends DocIdSetIterator { > private int doc,last; > > public SliceDocIdSetIterator(int first, int last) { > this.doc =first-1; this.last=last; > } > > public int docID() { > return doc; > } > > public int nextDoc() throws IOException { > if (++doc>last) doc=NO_MORE_DOCS; > return doc; > } > > public int advance(int target) throws IOException { > doc=target; > if (doc>last) doc=NO_MORE_DOCS; > return doc; > } > } > > > -Yonik > http://www.lucidimagination.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-dev-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org