-
Notifications
You must be signed in to change notification settings - Fork 273
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
Is there a way to get the inverse of a bitset? #686
Comments
There is |
@Dr-Emann has the correct answer: /**
* Compute the negation of the bitmap in the interval [range_start, range_end).
* The number of negated values is range_end - range_start.
* Areas outside the range are passed through unchanged.
*/
roaring_bitmap_t *roaring_bitmap_flip(const roaring_bitmap_t *r1,
uint64_t range_start, uint64_t range_end);
/**
* Compute the negation of the bitmap in the interval [range_start, range_end].
* The number of negated values is range_end - range_start + 1.
* Areas outside the range are passed through unchanged.
*/
roaring_bitmap_t *roaring_bitmap_flip_closed(const roaring_bitmap_t *x1,
uint32_t range_start,
uint32_t range_end);
I suspect not because this full range up to UINT32_MAX might insert 4 billions 1-bits in your bitmap... which is a lot. Typically, if a bit reversal is what you really need, you have a reasonable universe size... E.g., in the case of the C operator, the universe size might be 32 or 64. So if your bitmaps are in the range from 0 to 1000000, you do I am going to close this issue as the functionality is already present. |
Will also note, thanks to range containers, fully inverting an empty bitmap will "only" involve 65k full range containers, but yeah, you can do a lot better if you have a defined max that you actually care about. Will also also note, |
Looking at the headers, I don't see an easy way to invert a bitset. The equivalent of the C ~ operator.
We have an application that needs to do
LHS |= RHS
and alsoLHS |= ~ RHS
. The latter doesn't look doable with CRoaring. Can that be added?Thanks!
The text was updated successfully, but these errors were encountered: