Skip to content

Add functions to skip forward/backward with an iterator, and use it to simplify roaring_bitmap_range_uint32_array#741

Merged
lemire merged 2 commits intoRoaringBitmap:masterfrom
Dr-Emann:push-wlmxklopxtmr
Oct 1, 2025
Merged

Add functions to skip forward/backward with an iterator, and use it to simplify roaring_bitmap_range_uint32_array#741
lemire merged 2 commits intoRoaringBitmap:masterfrom
Dr-Emann:push-wlmxklopxtmr

Conversation

@Dr-Emann
Copy link
Member

  1. Introduce roaring_uint32_iterator_skip and roaring_uint32_iterator_skip_backward functions which advance an iterator by multiple positions efficiently.
  2. Use the new roaring_uint32_iterator_skip in conjunction with the existing roaring_uint32_iterator_read function to implement the roaring_bitmap_range_uint32_array function

The rust bindings will also be able to use the new skipping functions for implementing Iterator::nth.

@Dr-Emann Dr-Emann requested review from Copilot and lemire September 22, 2025 06:05
Copy link

Copilot AI left a 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 introduces efficient iterator skipping functionality to the roaring bitmap library. It adds forward and backward skip operations for iterators and refactors the range array function to use the new iterator-based approach.

  • Adds roaring_uint32_iterator_skip and roaring_uint32_iterator_skip_backward functions
  • Implements container-level skip operations for array, bitset, and run containers
  • Refactors roaring_bitmap_range_uint32_array to use the new skip functionality instead of the old complex implementation

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
include/roaring/roaring.h Adds public API declarations for iterator skip functions and updates documentation
include/roaring/containers/containers.h Declares container-level skip function APIs
include/roaring/roaring_array.h Removes declaration for old ra_range_uint32_array function
src/roaring.c Implements iterator skip functions and simplifies range array function
src/containers/containers.c Implements container-level skip operations for all container types
src/roaring_array.c Removes old ra_range_uint32_array implementation
tests/toplevel_unit.c Adds comprehensive tests for iterator skip functionality and improves existing test
tests/container_comparison_unit.c Adds container-level tests for skip operations and fixes assertion

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

This allows efficently skipping over items in an iterator.
Greatly simplify the implementation of roaring_uint32_iterator_skip
using `roaring_uint32_iterator_skip`. This also eliminates an unessisary
allocation, and possible failure. For backward compat,
`roaring_bitmap_range_uint32_array` still returns a bool, but it always
returns true since it can no longer fail.
@lemire lemire merged commit bcb7440 into RoaringBitmap:master Oct 1, 2025
18 checks passed
@Dr-Emann Dr-Emann deleted the push-wlmxklopxtmr branch January 2, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants