[C++] Add iterator-based variants of bit-run visitors
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
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:
```c++
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++
Contributor guide
Research direction
Start by reading the existing VisitBitRuns, VisitSetBitRuns, VisitTwoSetBitRuns, VisitBitBlocks, and VisitTwoBitBlocks entry points and their current C++ tests. Confirm the iterator variants support the shown range arguments and early-exit use case, with tests covering the run or block values and behavior for each variant.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100