-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[C++] Add iterator-based variants of bit-run visitors #51289
Open
Description
Describe the enhancement requested
VisitBitRuns, VisitSetBitRuns, VisitTwoSetBitRuns are useful in many cases but some times the caller needs to control the control flow, for example for returning early.
So it would be nice to be able to write:
for (const auto run : IterateBitRuns(bitmap, offset, length)) { // do something with run.position, run.length, run.set } // or: for (const auto run : IterateSetBitRuns(bitmap, offset, length)) { // do something with run.position, run.length } // or: for (const auto run : IterateTwoSetBitRuns( left_bitmap, left_offset, right_bitmap, right_offset, length)) { // do something with run.position, run.length }
The same transformation could be done for VisitBitBlocks, VisitTwoBitBlocks.
Component(s)
C++