[ https://issues.apache.org/jira/browse/LUCENE-3179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13054578#comment-13054578 ]
Uwe Schindler commented on LUCENE-3179: --------------------------------------- The check for negative indexes must be done to make the following loop work (which is standard to iterate backwards from "startBit" on all bits): {code:java} for (int i = bs.prevSetBit(startBit); i >= 0; i = bs.prevSetBit(i-1)) { // operate on index i here } {code} This would fail with AIOOBE when i=0 on the last iteration (happens if 0th bit is set), because bs.prevSetBit(i-1) has negative parameter. The exit condition is checked later, so -1 must be allowed. > OpenBitSet.prevSetBit() > ----------------------- > > Key: LUCENE-3179 > URL: https://issues.apache.org/jira/browse/LUCENE-3179 > Project: Lucene - Java > Issue Type: Improvement > Reporter: Paul Elschot > Priority: Minor > Fix For: 3.3, 4.0 > > Attachments: LUCENE-3179-fix.patch, LUCENE-3179.patch, > LUCENE-3179.patch, LUCENE-3179.patch, TestBitUtil.java, TestOpenBitSet.patch > > > Find a previous set bit in an OpenBitSet. > Useful for parent testing in nested document query execution LUCENE-2454 . -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org