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

The best way to merge multiple bit vectors? #279

Open
Anivie opened this issue Sep 29, 2024 · 0 comments
Open

The best way to merge multiple bit vectors? #279

Anivie opened this issue Sep 29, 2024 · 0 comments

Comments

@Anivie
Copy link

Anivie commented Sep 29, 2024

I am trying to merge multiple BitVecs, such that if a position has a 1 in one of the BitVecs, that position in the final set will store 1; if all the BitVecs have 0 in that position, the result will be 0. I am attempting to accomplish this task in the following way:

for each_class in mask {
    for all in mask_all.as_raw_mut_slice() {
        for current in each_class.mask.as_raw_slice() {
            *all |= *current;
        }
    }
}

But it doesn't seem to be working properly, how should I change it? This is the current version that works:

for each_class in mask {
    for (index, all) in each_class.mask.iter().enumerate() {
        if *all {
            mask_all.set(index, true);
        }
    }
}
@Anivie Anivie changed the title What is the best way to merge multiple bit vectors? The best way to merge multiple bit vectors? Sep 29, 2024
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