I didn't add a find_prev because I don't need it, although I can without much additional effort. Otherwise, this is pretty self explanatory, just an analogue of find_first() but for searching in reverse.
Details
Diff Detail
Event Timeline
(Note that I also added some tests for find_last, and while doing so noticed that there were no tests for find_first(), so I added those too.
llvm/include/llvm/ADT/SparseBitVector.h | ||
---|---|---|
141 | Don't you really just want counttrailingzeros, and the index is bitword_size - count trailing zeros? |
llvm/include/llvm/ADT/SparseBitVector.h | ||
---|---|---|
141 | I made the same mistake at first. Because the LSB is the bit with the lowest "index", we have to use countLeadingZeros. i.e. 0b00000000000000000000000000000110 has bits 1 and 2 set. The value we want returned from the function is 2. |
llvm/include/llvm/ADT/SparseBitVector.h | ||
---|---|---|
141 | This assumes we store these little endian. Anyway, i think you are correct, and if not, the test will fail, so :) |
Don't you really just want counttrailingzeros, and the index is bitword_size - count trailing zeros?