brettwooldridge / SparseBitSet

An efficient sparse bit set implementation for Java
Apache License 2.0
265 stars 33 forks source link

[#7] Implement previousClearBit and previousSetBit #12

Closed BrentDouglas closed 7 years ago

BrentDouglas commented 7 years ago

Both methods essentially look up the desired bit and search linearly backwards from that position. The allowed parameters and return values match those of the JDK's BitSet.

brettwooldridge commented 7 years ago

Thanks. Nice work.

BrentDouglas commented 7 years ago

Wow, thanks, that was fast. I think may have put a bug into previousOnClear when the value is just off the end of one of the arrays so there may be a follow PR on this.