Skip to content
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

Fast/convenient masking operations #419

Open
fbbdev opened this issue Dec 25, 2022 · 0 comments
Open

Fast/convenient masking operations #419

fbbdev opened this issue Dec 25, 2022 · 0 comments

Comments

@fbbdev
Copy link

fbbdev commented Dec 25, 2022

Currently one can perform in-place or, andnot and xor operations with a range parameter through the addRange, removeRange and flip methods. Range-based and can be simulated by two consecutive calls to removeRange:

bitmap.removeRange(0, a);
bitmap.removeRange(b + 1, bitmap.maximum() + 1);

It would be more convenient to have a method family like, e.g., mask and maskClosed implementing the same functionality directly.

It would also be helpful to have a family of methods for performing range-restricted updates, i.e. something like

bitmap1.add(otherBitmap, rangeStart, rangeEnd);
bitmap2.flip(otherBitmap, rangeStart, rangeEnd);
bitmap3.andnot(otherBitmap, rangeStart, rangeEnd);

whose semantics would be

Roaring maskedOp;
maskedOp.addRange(rangeStart, rangeEnd);
maskedOp &= otherBitmap;

bitmap1 |= maskedOp;
bitmap2 ^= maskedOp;
bitmap3 -= maskedOp;

Specialized methods could probably be much faster and more memory-efficient than the mask-based solution above.

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

No branches or pull requests

1 participant