-
Notifications
You must be signed in to change notification settings - Fork 243
fixing issue 22 : unset iterators #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for iterating over unset bits in a bitmap within a specified range. The implementation provides a new UnsetIterator method that returns values in [min, max] that are NOT contained in the bitmap, along with a helper Unset function for use with Go 1.23+ range-over-function.
Key changes:
- Added
unsetIteratortype with logic to iterate over unset values within a range - Added
Bitmap.UnsetIterator(min, max)method to create the iterator - Added
Unset(b, min, max)function for Go 1.23+ range-over-function support - Comprehensive test coverage for various edge cases
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| roaring.go | Implements unsetIterator struct and UnsetIterator method to iterate over unset bits in a range |
| iter.go | Adds Unset function for Go 1.23+ range-over-function support |
| iter_test.go | Comprehensive tests covering empty bitmaps, sparse bitmaps, edge cases, and early termination |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
It would be helpful if this returned IntPeekable. That would make it possible to iterate over all ranges efficiently (see #491 ). Maybe there's another way of doing that that I haven't thought of though? |
Ok. Done. |
|
Thanks for adding the Peekable capability. One passing thought after playing with this: it's arguably slightly confusing that this API call uses a uint32 closed range where other calls in the API (e.g. Also it often simplifies code to be able to use a zero-length interval without special-casing, which isn't possible with this API in general - specifically I don't think there's any way to specify a zero-length interval at the very start, because [0, -1] isn't possible with uint32. |
|
@rogpeppe Given that this is a new feature, we can break the API now. Feel free to issue a pull request. We can introduce breaking changes at this point. |
Fixes #22