uschindler commented on code in PR #12194: URL: https://github.com/apache/lucene/pull/12194#discussion_r1129102882
########## lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java: ########## @@ -286,6 +286,33 @@ public int nextSetBit(int index) { return DocIdSetIterator.NO_MORE_DOCS; } + @Override + public int nextClearBit(int index) { + assert index >= 0 && index < numBits : "index=" + index + ", numBits=" + numBits; + + int wordIndex = index >> 6; + long word = bits[wordIndex] >> index; // skip all the bits to the right of index + + if (word == 0) { + return index; + } + + int n = Long.numberOfTrailingZeros(~word); + + if (n + index % Long.SIZE < Long.SIZE - Long.numberOfLeadingZeros(bits[wordIndex])) { + return index + n; + } + + while (++wordIndex < numWords) { + word = bits[wordIndex]; + if (Long.bitCount(word) != Long.SIZE) { // there are 0s in this word Review Comment: Theres also a test missing, see below comment. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org